CI 4.18 -> 4.20 causes RouterException - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: CI 4.18 -> 4.20 causes RouterException (/showthread.php?tid=82070) |
CI 4.18 -> 4.20 causes RouterException - sjender - 06-08-2022 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. RE: CI 4.18 -> 4.20 causes RouterException - kenjis - 06-08-2022 Check your routes: Code: $ php spark routes RE: CI 4.18 -> 4.20 causes RouterException - sjender - 06-08-2022 | 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? RE: CI 4.18 -> 4.20 causes RouterException - kenjis - 06-08-2022 (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. RE: CI 4.18 -> 4.20 causes RouterException - sjender - 06-09-2022 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? RE: CI 4.18 -> 4.20 causes RouterException - kenjis - 06-09-2022 Sorry, it seems a bug. '\App\Controllers\backend\Dashboard::index' should work. Can you try this patch? Code: --- a/system/Router/RouteCollection.php RE: CI 4.18 -> 4.20 causes RouterException - sjender - 06-09-2022 Yep, that seems to work! Thanks. Is this fix going to be in next versions of CI? RE: CI 4.18 -> 4.20 causes RouterException - kenjis - 06-09-2022 I sent a PR to fix this: https://github.com/codeigniter4/CodeIgniter4/pull/6104 |