MufidJamaluddin / Codeigniter4-HMVC

CodeIgniter 4 Starter with HMVC
MIT License
67 stars 39 forks source link

Error adding new module #6

Closed mjquimbita closed 2 years ago

mjquimbita commented 4 years ago

Hi, i added a new module Login and modifit Routes.php to set default controller; then I added a new module Modulos from command line also update like the indications. But when I use http://localhost:8080/Modulos/index the result is 404 error like this Controller or its method is not found: \App\Modules\Login\Controllers\Modulos::index. I also use the function: return redirect()->to('/Modulos/index'); and is the same error. Whast can I do??? Thanks

MufidJamaluddin commented 2 years ago

Hi @mjquimbita, could you put your source code to this PR comments? Tq :pray:

vimsmak commented 2 years ago

Hi @MufidJamaluddin, How can I use custom-created Libraries? I just create a simple test class in libraries folder but i cant access. Example: <?php

namespace App\Libraries;

class OciInteration { public function Test() {

code...

    return 'Test';
}

public function upload_file_oracle($bucket_name, $folder_name, $file_name)
{
    echo "HI";
    exit;
}

} // how can I use this in my modules controller? in my controller, I added this library but its showing error use App\Libraries\OciInteration; In my controller, I created the instance of this class but it shows an error.

Class 'App\Libraries\OciInteration' not found

Can you please help me out.

MufidJamaluddin commented 2 years ago

Hi @vimsmak, you could use PSR-4 standard. Simply, import from your libraries folder.. :pray:

Example:

<?php namespace App\Modules\Admin\Controllers;

use App\Libraries\YourLibraryClass;

Reference:

vimsmak commented 2 years ago

Yes, I am doing the same as your answer still I am getting the error "class not found". if I place my custom library class in the vendor folder then its works. but if I place it in the app\libraries folder then it's showing an error.

mdestafadilah commented 2 years ago

Hi @vimsmak, you could use PSR-4 standard. Simply, import from your libraries folder.. 🙏

Example:

<?php namespace App\Modules\Admin\Controllers;

use use App\Libraries\YourLibraryClass;

Reference:

coba sendiri deh pak. kayaknya ada erorr jg.

MufidJamaluddin commented 2 years ago

Hi @mdestafadilah , Hi @vimsmak , please add namespace in your library for use import. :pray:

On my machine, the Library worked.

Screenshot (1652)

Screenshot (1653)

MufidJamaluddin commented 2 years ago

Yes, I am doing the same as your answer still I am getting the error "class not found". if I place my custom library class in the vendor folder then its works. but if I place it in the app\libraries folder then it's showing an error.

First, please add namespace App\Libraries; in top of your library class.

Second, use use keyword for import it. Example: use App\Libraries\YourLibraryClass;

Cc @vimsmak @mdestafadilah

🙏

ArnandoFajar commented 2 years ago

very good i can try it

MufidJamaluddin commented 2 years ago

Hi @mjquimbita, @vimsmak, @mdestafadilah, and @ArnandoFajar, there're new release (v0.2.2) to simplify the module creation using php spark module command.

ArnandoFajar commented 2 years ago

Ty mas @MufidJamaluddin