Welcome Guest, Not a member yet? Register   Sign In
Failed to auto loading the routes.php
#1

(This post was last modified: 07-28-2021, 08:45 AM by mjamilasfihani.)

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?
A man behind CI 4 Assets Generator
Reply
#2

Show your autoload file.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(This post was last modified: 07-28-2021, 11:14 PM by mjamilasfihani.)

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
A man behind CI 4 Assets Generator
Reply
#4

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
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB