Welcome Guest, Not a member yet? Register   Sign In
Auto-Routing don't work with 4.4.0

It seems Auto-Routing doesn't work as before with CI 4.4.0 and new Config\Routing.php file.
We have to add \\ at the end of $defaultNamespace if we don't want to have a 404 page with method unavailable.
Before, when we use $routes->setDefaultNamespace in Config\App.php file, it add automatically \\ at the end of the string.
Is it a bug or a feature ? Or me perhaps...


Can you show the sample code to reproduce the issue?
And do you use Auto-Routing Legacy or Improved?

I've just test with a fresh project and can reproduce it simply.
So, I download CI 4.4.0 and set only this :

In .env
PHP Code:
CI_ENVIRONMENT development 

In Config\Routing.php
PHP Code:
public bool $autoRoute true

In Config\Feature.php, the parameters still set to Legacy
PHP Code:
public bool $autoRoutesImproved false

Then, I create an Auth.php file in app\Controllers\ folder
PHP Code:

namespace App\Controllers;

Auth extends BaseController
    public function index(): string
        return view('welcome_message');

When I want to access http://localhost:8080/auth, I have a 404 page with this message
Controller or its method is not found: \App\ControllersAuth::index

Thank you!

I sent a PR to fix: https://github.com/codeigniter4/CodeIgniter4/pull/7871

Is there a planned release to include this fix anytime soon?

See https://github.com/codeigniter4/CodeIgniter4/pull/7874

All development is done in the main GitHub repository.
CodeIgniter4 is a true community-driven framework.
The more you all contribute, the faster it will be released.

Theme © iAndrew 2016 - Forum software by © MyBB