"Rowan Collins" wrote in message news:ae15f883-bdba-89ea-9e6a-6e3b09745...@gmail.com...

On 29/01/2017 15:37, Wes wrote:
Curious that those who are posting here put all functions in the same file.
So, why don't you just require_once('Namespace/functions.php') ?

By that argument, why not just require_once('Namespace/ClassName.php)? It turns out that many people find autoloading a much more convenient and manageable solution.

In particular, the standardisation of autoloading provided by PSR-0 and PSR-4 has been central to the success of Composer, and the ecosystem of reusable components that it promotes.

Autoloading functions, either one by one, or namespace by namespace, is a logical extension of that, with all the same benefits. Unfortunately, it has some unique complications due to the way PHP resolves namespaced vs global function names. Please have a look through the archives of the list if you want to know more; there's been too much discussion already to re-hash it all here.

Regards,


While it has already been good practice to put each class in its own file, it has never been good practice (at least with all the online tutorials and examples that I have read since 2002) to put each function into its own file.

Autoloading classes might be practical and easily implemented, but autoloading functions is a can of worms, especially when you throw in namespaces. I neither need nor want it in my code.

--
Tony Marston


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to