CI 4.18 -> 4.20 causes RouterException |
Hi all,
I am upgrading from 4.18 to 4.20. But now I receieve numerous RouterExceptions. For example: Controller or its method is not found: \App\Controllers\Login::index This is de routes.php rule: PHP Code: $routes->get('/beheer', 'Login::index'); And I do have a app/Controllers/Login.php file with an index() method in it. I can't seem to find anything in the changelog what will cause this behaviour.
Check your routes:
Code: $ php spark routes
| GET | beheer | \App\Controllers\Login::index | | toolbar |
It's present.... Only difference.... App is uppercase, and my folder name is app (lowecase). Can that be the problem? (06-08-2022, 09:37 AM)sjender Wrote: Only difference.... App is uppercase, and my folder name is app (lowecase). No. Code: Controller or its method is not found: \App\Controllers\Login::index This error occurs when the controller class can't be autoloaded. Did you customize something in autoload configuration? Quote:I can't seem to find anything in the changelog what will cause this behaviour. Yes, unless there is a bug we don't know, there is no change in that area.
I think I've found the problem...
It's an url_to() issue. I have this line to redirect to the dashboard when a user is already logged in: PHP Code: return redirect()->to(url_to('\App\Controllers\backend\Dashboard::index')); This line throws the error. But when I change it to: PHP Code: return redirect()->to(url_to('backend\Dashboard::index')); It works, but I have many uses of url_to(), it would be quite some work to modify all these occurences, and with a risk of forgetting one. Does anyone know, why this is a problem all of a sudden? And is there a way of making it work like it used to work?
Sorry, it seems a bug.
'\App\Controllers\backend\Dashboard::index' should work. Can you try this patch? Code: --- a/system/Router/RouteCollection.php
Yep, that seems to work!
Thanks. Is this fix going to be in next versions of CI?
I sent a PR to fix this: https://github.com/codeigniter4/CodeIgniter4/pull/6104
|
Welcome Guest, Not a member yet? Register Sign In |