Web lists-archives.com

Re: [PHP] Many Small Files or Larger Utility Files

On 06/21/2016 11:52 AM, Christoph Becker wrote:
On 21.06.2016 at 15:57, Larry Garfield wrote:

If you're using a mostly procedural code base, then clustering functions into manageable chunks makes sense. One function per file is ridiculous and unmanageable.
That depends on the length of the function.  I've seen functions
consisting of several hundred lines, and heard about even longer
functions.  I don't recommend this coding style, though.

As have I, and I run screaming from it, too. :-)

Generally speaking, "class per file and don't sweat it" is the
conventional approach, and what I'd recommend in most cases.
Well said. :)

However, if there is no bytecode cache available on the production
system for whatever reason, it's still possible to merge all (or some
reasonable subsets of) classes into a single file (a few files) during
build time.

True, but in what situation would you not have an opcode cache available that is not one of:

1) Your PHP version is so out of date you may as well give up, because it's already insecure. 2) Your webhost is so terrible that the best thing you can do for your app is to get a new webhost.

An opcode cache should just be assumed on any modern PHP installation; if it's not there, there are other, much larger problems to resolve first.

--Larry Garfield

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php