Autorouting is not working for Controller created inside sub-directory of Controllers |
I have created a controller in a sub-directory under app/Controllers/Admin but unable to access it via autorouting methods like localhost/admin . The code for that is given below:
PHP Code: <?php namespace App\Controllers\Admin; I think I have set up everything correctly from the docs. I have installed the ci4 using composer and adjusted the .env for development, added virtual host too. However, only custom route is working and also when I specify the whole directory for the controller like localhost/admin/admin. Code: /** Please Help if I made any silly mistakes or is this a bug? The error I am getting is : 404, the controller cannot be found
You also need to pass along the sub-directory
localhost/admin/admin What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(07-24-2020, 10:07 AM)InsiteFX Wrote: You also need to pass along the sub-directory But I have expanded the BaseController and also specified it's required namespace. It doesn't make sense to pass the sub-directory in the URL to get the controller. I should be able to gain the controller directly with localhost/admin,
Your sub-controller needs to be named Home. As the auto route grabs your default controller name.
App\Controllers\Admin\Home https://codeigniter.com/user_guide/incom...irectories |
Welcome Guest, Not a member yet? Register Sign In |