Helpers and Other Conventions |
I don't know that the style guide is going to change at this point, honestly. While I didn't write the style guide, I think if you look at PHP's own functions, they're all named snake_case so, to me, it makes sense in that respect.
About namespacing, I'll consider it. I haven't done much work with namespacing and functions, but it seems like then everything gets even wordier? Instead of form_open(), you're now doing we'd have to use \CodeIgniter\Helpers\Forms\form_open(), which is kind of ugly. I suppose we could put "use" statements in the views but that gets even uglier. So, not sure if there's an elegant way to make that work at the moment.
There's a way to get around that. See my pre PHP7 sample http://icecream.me/2a74daa0983861570d3a50d0d07e4714. For reference, you may refer to http://php.net/manual/en/language.namesp...orting.php and search for "Group use declarations". Hope it helps.
PS: Don't mind the require_once() and stuff
Long live CodeIgniter!
Too many namespaces within 1 framework and its app..
Perhaps all functions should be declared under CodeIgniter namespace only. Best VPS Hosting : Digital Ocean
(06-28-2016, 09:06 PM)kilishan Wrote: Here's the styleguide: https://bcit-ci.github.io/CodeIgniter4/c...guide.html (06-29-2016, 11:12 PM)sv3tli0 Wrote: Too many namespaces within 1 framework and its app.. I believe the goal is to avoid name conflicts.
Long live CodeIgniter!
(06-30-2016, 12:11 AM)prezire Wrote: I believe the goal is to avoid name conflicts. Its good goal but 1 avoid of conflicts should not create others.. Helper is too common word as Config which is used already for namespace.. And having CodeIgniter, App, Config, Helper namespaces just within 1 sample app its too much I think.. At least for Functions I don't see any problem to have them just under CodeIgniter namespace. Perhaps some system option to alias them into the APP namespace can be helpful. By the way many calls of USE (in controllers / models / views ) is something common this days. My IDE PHPstorm even auto add it at the start of the file when you are using some class/function under some namespace.. So this is the way how PHP is made and developers must accept it I think. Best VPS Hosting : Digital Ocean
Without getting hungup on specific names, etc, it sounds like something along the lines of the following might be a good approach. Thoughts?
CodeIgniter3 ... system/helpers/url_helper.php Code: if ( ! function_exists('site_url')) application/whatever... Code: $this->load->helper('url'); CodeIgniter4?? ... system/helpers/URL.php Code: namespace CodeIgniter\Helpers\URL; application/whatever... Code: use CodeIgniter\Helpers\URL;
James Parry
Project Lead (06-29-2016, 06:13 AM)kilishan Wrote:(06-29-2016, 01:17 AM)Narf Wrote: It's not OOP at all, you're not using objects. No ... classes are classes. When you don't instantiate them, there are no objects. (06-30-2016, 12:53 AM)jlp Wrote: application/whatever... This is most comfortable way. Controller/Model/View there is no difference, such usage is normal for any PHP code.. And there is no reason why namespaces usage shouldn't exists in a view file, at least until this view is a PHP file. Best VPS Hosting : Digital Ocean
|
Welcome Guest, Not a member yet? Register Sign In |