![]() |
Helpers and Other Conventions - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=31) +--- Thread: Helpers and Other Conventions (/showthread.php?tid=65588) |
RE: Helpers and Other Conventions - kilishan - 06-29-2016 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. ![]() RE: Helpers and Other Conventions - prezire - 06-29-2016 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.namespaces.importing.php and search for "Group use declarations". Hope it helps. PS: Don't mind the require_once() and stuff ![]() RE: Helpers and Other Conventions - sv3tli0 - 06-29-2016 Too many namespaces within 1 framework and its app.. Perhaps all functions should be declared under CodeIgniter namespace only. RE: Helpers and Other Conventions - prezire - 06-30-2016 (06-28-2016, 09:06 PM)kilishan Wrote: Here's the styleguide: https://bcit-ci.github.io/CodeIgniter4/contributing/styleguide.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. RE: Helpers and Other Conventions - sv3tli0 - 06-30-2016 (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. RE: Helpers and Other Conventions - jlp - 06-30-2016 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; RE: Helpers and Other Conventions - Narf - 06-30-2016 (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. RE: Helpers and Other Conventions - sv3tli0 - 06-30-2016 (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. RE: Helpers and Other Conventions - prezire - 06-30-2016 I like it too. But reserved words are not allowed like below: PHP Code: use Helpers\Array; I know you guys can find a way ![]() RE: Helpers and Other Conventions - Narf - 06-30-2016 (06-30-2016, 05:21 AM)prezire Wrote: I like it too. But reserved words are not allowed like below: The array helpers are useless. |