[pkg-php-pear] [Symfony (and more)] class loader in Composer packages

"David Prévot" david at tilapin.org
Wed Apr 1 21:50:22 UTC 2015

Hi Daniel and all,

I’ve recently been providing autoload.php files in the PHP (Composer)
packages I’m currently maintaining (following Prach lead IIRC).

It mostly workarounds the lack of proper autoloader from Composer, and
allows one to load (statically) dependency classes without the need to use
something like the ClassLoader Element from Symfony (and thus fixed bugs
like #777380).

Static loaders should also be a performance improvement compared to
dynamic ones.

In order to do so, a simple phpab call is enough if no dependencies are


If some dependencies are involved, I also used a template to load them on
top of the actual class loader:


I’d now like to (start to) do the same in Symfony now. The tricky part is
that, unlike the usual one-binary-per-source PHP package, making sure that
the autoload.php files are kept up to date (dependency-wise) will be a bit
more painful since there are a lot of composer.json files to check on
update (currently 42 packages in 2.6.6, and counting).

If you don’t like it, please do object ASAP (so I won’t lose too much time
on it for nothing ;). I’ll start pushing the changes in a WIP branch so we
can review them before accepting them (and also not pollute master if we
end up aiming at another approach).

Please note that Composer is also pending in NEW, but I don’t know yet how
we may integrate it to produce a proper system-wide classloader (via a
postinst hook?)
 I can make it available in people.d.o if you want to
start playing with it and don’t fancy rebuilding it yourself.




More information about the pkg-php-pear mailing list