![]() |
Hi,
i setup a new Project with CI4. app/Config/Feature.php PHP Code: public bool $autoRoutesImproved = true; app/Config/Routing.php PHP Code: public string $defaultController = 'Home'; app/Config/Routes.php PHP Code: <?php app/Controllers/Home.php PHP Code: <?php But i get a 404 on Https://xxxxx.de/Test with following error Quote:Cannot access the default controller "\App\Controllers\Home::getTest" What am i missing? I don't wanna write every route in app/Config/Routes.php Best regards.
The basic URL pattern is "https://example.com/class/method/arg"
See https://codeigniter.com/user_guide/incom...i-segments If you want to have "https://xxxxx.de/test", create Test::getIndex().
Thank you for your reply kenjis,
I read the Docs, not 100% but 70-80% and i have some experience with some CI4 Projects, but never use the Default Controller with more methods. The following urls didn't work, but i dont know why not. Https://xxxxx.de/Home Quote:Cannot access the default controller "\App\Controllers\Home" with the controller name URI path.Https://xxxxx.de/Home/Test Quote:Cannot access the default controller "\App\Controllers\Home" with the controller name URI path. What am i missing or is it not possibly to have more than Index method in the default Controller? Best regards (06-21-2024, 02:01 AM)TakonSix Wrote: is it not possibly to have more than Index method in the default Controller? No, it is not possible. Quote:Important (06-21-2024, 02:01 AM)TakonSix Wrote: The following urls didn't work, but i dont know why not. That is for security reasons. Auto Routing Improved permits only one URI for a controller method. In this case, Home::getIndex() -> https://xxxxx.de/ (not https://xxxxx.de/home) (06-21-2024, 02:27 AM)kenjis Wrote:(06-21-2024, 02:01 AM)TakonSix Wrote: is it not possibly to have more than Index method in the default Controller? I am sorry that i read over this O.o Thank you for taking the time to explain this to me.
It is true that auto routing improved is a bit complex and difficult to understand.
If you use it now, I recommend you enable $translateUriToCamelCase. See https://codeigniter.com/user_guide/incom...-camelcase Also, spark routes command may help you to understand. See https://codeigniter.com/user_guide/incom...ark-routes |
Welcome Guest, Not a member yet? Register Sign In |