CodeIgniter Forums
Codeigniter using namespace for version 3.x? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17)
+--- Thread: Codeigniter using namespace for version 3.x? (/showthread.php?tid=61827)



Codeigniter using namespace for version 3.x? - nobitacnt - 05-22-2015

why not use the namespace in codeigniter app?


RE: Codeigniter using namespace for version 3.x? - Mohammadhzp - 05-22-2015

Because CI3 support PHP 5.2.4 and namespaces introduced in PHP 5.3


RE: Codeigniter using namespace for version 3.x? - mwhitney - 05-22-2015

You can use namespaces in your application, but CI itself doesn't use them, and its loader doesn't support them, so you'll have to load namespaced classes on your own. Since CI will load Composer for you if you set a config value, it's usually pretty easy to load and use namespaced classes as you would in other frameworks.


RE: Codeigniter using namespace for version 3.x? - xvieri - 09-28-2015

I try to do but I need more details or a sample, could you please write a little sample using ci3 hmvc and namespacing
regards


RE: Codeigniter using namespace for version 3.x? - Vimal - 09-29-2015

No you can't use namespace in ci 3.x version until core files change.
I suggest you to not using namespace in core files like controller,model and default libraries.
But u can use namespace in extra added libraries with composer. google it composer autoloader.


RE: Codeigniter using namespace for version 3.x? - kenjis - 09-29-2015

You can't use namespaces in controllers.

You can use namespaces in models and libraries, but in that case you don't use $this->load->***.
You just instantiate them with new operator like pure PHP.