[pkg-php-pear] How to replace "require vendor/autoload.php" in deb package

Robin Gustafsson robin at rgson.se
Fri Feb 11 16:57:30 GMT 2022


On Fri, Feb 11, 2022 at 3:47 PM David Prévot <david at tilapin.org> wrote:
> Hi,
> Le 11/02/2022 à 10:28, Fab a écrit :
> > If a project uses:
> >
> > require_once vendor/autoload.php
> >
> > to autoload the classes defined in composer.json, how should that be changed
> […]
> > Should it be changed to as many such lines as needed?
> >
> > require_once /usr/share/php/pkg1/autoload.php
> Please, rather use “require_once 'pkg1/autoload.php';”, or let
> phabtpl(1) do it for you. /usr/share/php/ is expected to be in the PATH.
> > Or is there a way to make it single-lined like this?
> > require_once /usr/share/php/Composer/autoload.php
> > (I guess we can't install pkg1, pkg2... into /usr/share/php/Composer)
> There should be no need to depend on the composer package.

To expand on this: The vendor/autoload.php file generated by Composer
loads both dependencies and the project's own code. You should instead
create and install your own autoload.php file that 1) loads the
autoload.php files shipped by each of your dependencies in Debian and
2) registers a static autoloader to load the code in your package.

phpab(1) can generate an autoloader capable of loading your packages'
classes (part 2 above).
phpabtpl(1) can generate a template for you that you can use with
phpab to also load the dependencies (part 1 above).

Several of the more recently updated PHP packages [1] show how to
combine these tools.

[1] https://salsa.debian.org/php-team/pear?sort=latest_activity_desc


More information about the pkg-php-pear mailing list