Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98038 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 77158 invoked from network); 30 Jan 2017 09:16:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Jan 2017 09:16:49 -0000 X-Host-Fingerprint: 87.75.96.78 static-87-75-96-78.vodafonexdsl.co.uk Received: from [87.75.96.78] ([87.75.96.78:25981] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A7/E2-51557-0840F885 for ; Mon, 30 Jan 2017 04:16:49 -0500 Message-ID: To: internals@lists.php.net References: <9113D065-B94A-4CA2-9420-56963C703ECA@gmail.com> <81.F3.06271.F11CD885@pb1.pair.com> In-Reply-To: Date: Mon, 30 Jan 2017 09:16:44 -0000 Lines: 2 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="utf-8"; reply-type=response Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal Importance: Normal X-Newsreader: Microsoft Windows Live Mail 16.4.3564.1216 X-MimeOLE: Produced By Microsoft MimeOLE V16.4.3564.1216 X-Posted-By: 87.75.96.78 Subject: Re: [PHP-DEV] Not autoloading functions From: TonyMarston@hotmail.com ("Tony Marston") "Rowan Collins" wrote in message news:ae15f883-bdba-89ea-9e6a-6e3b09745288@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