CodeIgniter Forums
Failed to auto loading the routes.php - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Failed to auto loading the routes.php (/showthread.php?tid=79803)



Failed to auto loading the routes.php - mjamilasfihani - 07-28-2021

Hi, I have a weird problem. I have set my namespace and put my Routes.php in acme/Home/Config directory, sadly the autoloading can not find Routes.php file. Any idea to fix this? Thank you Smile

PHP ver 7.3
CodeIgniter 4.1.3

But the MythAuth Routes.php can autoloading by CodeIgniter. Any suggestion?


RE: Failed to auto loading the routes.php - InsiteFX - 07-28-2021

Show your autoload file.


RE: Failed to auto loading the routes.php - mjamilasfihani - 07-28-2021

PHP Code:
// My Autoload
public $psr4 = [
    APP_NAMESPACE => APPPATH// For custom app namespace
    'Config'      => APPPATH 'Config',
    'Myth\Auth'   => APPPATH 'ThirdParty/myth-auth/src',
    'Acme'        => ROOTPATH 'acme',
];

// My Controller
// Location : ROOTPATH . 'acme/Home/Controllers'
namespace Acme\Home\Controllers;

use 
App\Controllers\BaseController;

class 
Test extends BaseController
{
   public function index()
   {
       echo "string";
   }
}

// My Route
// Location : ROOTPATH . 'acme/Home/Config'
$routes->get('test''\Acme\Home\Controllers\Test::index');

// And the result is
// Controller or its method is not found: \App\Controllers\Test::index 

For now, it's okay for me because I use MVC instead. But I'll try to check later with a fresh CodeIgniter4


RE: Failed to auto loading the routes.php - InsiteFX - 07-29-2021

Your autoload is wrong sould be like below.

PHP Code:
'Acme\Home'        => ROOTPATH 'acme/home',

Trey thatI create modules all the time and they always work.

You need to give it the right path