Controllers under subfolder |
It should not be put inside the Libraries folder it's not a Library Class it's a Controller Class.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(07-02-2016, 01:02 AM)sv3tli0 Wrote: Remember that MY_ classes existed in the old CI versions because there were no namespaces.. Now in CI 4 you are able simply to create App/Controllers/Controller and to use it from your other controllers.. Yes. I agree. CI-4 have different phylosophy than CI-3. (07-02-2016, 01:02 AM)sv3tli0 Wrote: Remember that MY_ classes existed in the old CI versions because there were no namespaces.. Now in CI 4 you are able simply to create App/Controllers/Controller and to use it from your other controllers..The term of "MY_Controller" or "custom controller" is only example for controller extends to \CodeIgniter\Controller and it is intended to be extends for any controller that having common behaviour/task to be done before it executed or some method(like AdminController verify user role before give access to any users). (07-02-2016, 03:19 AM)InsiteFX Wrote: It should not be put inside the Libraries folder it's not a Library Class it's a Controller Class.Yes, it not recommended to put inside libraries folder. The "custom controller" should be organize in one folder. And controllers folder should only contain controller visitable by user.
Keep calm.
(07-02-2016, 03:40 AM)titounnes Wrote:(07-02-2016, 01:02 AM)sv3tli0 Wrote: Remember that MY_ classes existed in the old CI versions because there were no namespaces.. Now in CI 4 you are able simply to create App/Controllers/Controller and to use it from your other controllers.. Yes, absolutely different philosophy. The MY_classes will extends the base classes and each classes only have one job/situation to handle. But for controller you need multiple classes to handle different type of situation such as AdminController, PublicControler and etc. What I did in CI3 is, by having multiple class in one MY_Controller.php(also can be done by other way). As in CI4, thanks to namespace.
Keep calm.
(07-02-2016, 02:06 AM)arma7x Wrote:(07-01-2016, 10:07 PM)fromberg Wrote: Hi All, Hi arma7x, I highly appreciate your help, it works now. Just curious, should this be done like this? Shouldn't it be working automatically? Thanks and regards, (07-02-2016, 07:24 AM)fromberg Wrote:(07-02-2016, 02:06 AM)arma7x Wrote:(07-01-2016, 10:07 PM)fromberg Wrote: Hi All, Read explanation here from kilishan. But only controller with namespace(if I'm not wrong) you need to define route; PHP Code: $routes->add('ajax/test', 'Test::index', ['namespace' => 'App\Controllers\Ajax']);
Keep calm.
Thanks to this thread I have identified a couple of issues with the Routing. In part, was my original assumptions turned out incorrect - I thought the two philosophies would be used separately. Either you had a namespaced controller that was specified in the routes file, or the auto-routed version to stuff in the controller folder, where the classes were in the global namespace.
Listening to your feedback, I've gone back and fixed one issue that was keeping non-namespaced controllers from being auto-routed last night. Though I'm trying to find a nice way to make it testable currently. ![]() So - thanks for the feedback! And, have patience, we'll work the bugs out. ![]()
The person that is having trouble on a windows system you need to setup ENVIRONMENT VARIABLES in the windows control panel you may also need to edit the C:\Windows\System32\drivers\etc\host
host is a file that defines the windows localhost sometime the 127.0.0.1 is remarked out and you need to un-remark it. You can use notepad to edit the file. Make sure you save it afterwards and restart your servers etc; What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(07-10-2016, 04:59 AM)InsiteFX Wrote: The person that is having trouble on a windows system you need to setup ENVIRONMENT VARIABLES in the windows control panel you may also need to edit the C:\Windows\System32\drivers\etc\host Or use PHP: Built-in web server "php -S 127.0.0.1:xxxx -t /path/to/public" for those having problem when using base_url(), site_url() and current_url(). The only way to visit webapp in browser, the URL should be http://127.0.0.1:xxxx not http://127.0.0.1/path/to/public
Keep calm.
@ arma7x
I do not get your point on this because http://127.0.0.1/path/to/public Works just fine on my Windows system and has for years but now I use VirtualHosts What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |