![]() |
No Controller Call In Controller Anymore - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Feature Requests (https://forum.codeigniter.com/forumdisplay.php?fid=29) +--- Thread: No Controller Call In Controller Anymore (/showthread.php?tid=67669) |
No Controller Call In Controller Anymore - LukasStribrny - 03-22-2017 Hi there, I would like to make feature request to the thread named 'No Controller Call In Controller Anymore'. I have created this for CodeIgnitor 3 and it would be nice to have it in the new version CI 4. This is just an idea of how it's done : Code: Get the first registered numeric key You can have look in my code : Click here to see : "No Controller Call In Controller Anymore" I know it's not maybe the ideal way of creating what i have done,because it's not actually accepting the id yet. It actually still need some tweeking,which i will do soon or later. Well and why i actually created this tweak ? 1. I've seen many people over the internet try to do it ...than they got's some issue with session.php or other issues,even i've got that issue when i was trying for example to have nice url when called controller in controller.Which CodeIgnitor is not designed for. 2. It is good to have a structure of the controllers to keep them more organised instead of have too many in one folder. Incease if i forgot something i'll write it later. I was writing this in rush. RE: No Controller Call In Controller Anymore - Update - LukasStribrny - 04-01-2017 Just to let you know that now classs "My_Router" it's working as it should. It would be great if you intergrate this to the "CI_Router" core. So how it's working? Lets start with the base. Default old settings : controllers->Welcome.php default url : PROTOCOL://your-site.extension/ PROTOCOL://your-site.extension/Welcome PROTOCOL://your-site.extension/Welcome/index Default new settings : after applying the code to the core it will automaticly redirect internet browser to the default_controller and it's default method. So if user enter : PROTOCOL://your-site.extension/ it will directly become : PROTOCOL://your-site.extension/Welcome/Index and that's not all. The other thing is when developer of the app want to have controllers organised like so : Lets just for now pretend that we are now creating a structure of the controllers and developing new application. Simple view : The developer change a setting in the default_controller to class "Web". that means the url will look like this : PROTOCOL://your-site.extension/Web/Index Next thing is that the developer want to act with user login for example which can be done this way : the developer don't have to create any method called "User" where it will usualy operate with the user action. Instead of that developer can create same named folder "Web" as the main class and create "User" class inside the folder with method "Login". now we have : controllers->Web->User.php and url : PROTOCOL://your-site.extension/Web/User/Login PROTOCOL://your-site.extension/Web/User/Logout PROTOCOL://your-site.extension/Web/User/ResetPassword Now the developer want to have a profile for user with option to view,delete or edit profile. It can be done the same way as above. All the methods can accept the id of the profile (by ID i mean some number). example : Create folder with the subclass name "User" and a new class inside with the name Profile. so we have : controllers->Web->User->Profile.php and url : PROTOCOL://your-site.extension/Web/User/Profile/View/1 PROTOCOL://your-site.extension/Web/User/Profile/Edit/1 PROTOCOL://your-site.extension/Web/User/Profile/Delete/1 This feature will sort out : 1. Developer don't have to use too much settings in route to re-route and to have nice and simple url. 2. Keep controllers more organised and to have less code in each controller. 3. Developer can always continue use CodeIgniter the usuall way. 4. When intergrated,Developer don't need to write another file "My_Route.php". Thanks for reading and I hope this feature will be in CI 4 PS; Don't hesitate to contact me if anyone will need answers. |