[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,
Ive recently been providing autoload.php files in the PHP (Composer)
packages Im 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
involved:
https://anonscm.debian.org/cgit/pkg-owncloud/php-sabre-vobject.git/tree/debian/rules#n8
If some dependencies are involved, I also used a template to load them on
top of the actual class loader:
https://anonscm.debian.org/cgit/pkg-owncloud/php-sabredav.git/plain/debian/autoload.php.tpl
https://anonscm.debian.org/cgit/pkg-owncloud/php-sabredav.git/tree/debian/rules#n8
Id 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 dont like it, please do object ASAP (so I wont lose too much time
on it for nothing ;). Ill 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 dont 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 dont fancy rebuilding it yourself.
https://ftp-master.debian.org/new/composer_1.0.0~alpha9+dfsg-1.html
Regards
David
More information about the pkg-php-pear
mailing list