[Kolab-devel] PHP composer and packaging

Thomas Brüderli bruederli at kolabsys.com
Fri Feb 7 09:23:51 CET 2014


Mathieu Parent wrote:
> Hello all,
> 
> 2014-02-05 11:05 GMT+01:00 Thomas Brüderli <bruederli at kolabsys.com>:
> [..]
>> Or we specify an entirely new way to define and handle PHP library
>> dependencies which can work for both development and distribution.
>>
>> Does anybody have experience with this topic and or even found a nice
>> working solution how to deal with PHP packages? Please speak up!
>>
>> Let's gather the options and stakes on this topic and find a sustainable
>> way for the ongoing Kolab development.
> 
> I couldnt agree more: composer is for developers and doesn't help much
> packagers as it describe dependencies but not file paths.
> 
> In the Debian pkg-php team, we have a tool named pkg-php-tools which
> converts automatically PEAR/PECL or Composer deps to Debian deps. It
> also ensure files are installed in the right place (PEAR/PECL only).

I'd say that's a start. What about this idea:

1. Create a package with composer and its autoloading magic and install
it in a global location like /usr/share/php:

  /usr/share/php/composer.phar
  /usr/share/php/vendor/autoload.php
  /usr/share/php/vendor/composer/

2. Create individual packages for composer-based libraries and install
them to /usr/share/php/vendor/. e.g.

  /usr/share/php/vendor/sabre/dav
  /usr/share/php/vendor/sabre/vobject
  /usr/share/php/vendor/sabre/symfony/yaml

3. After installing a package, execute

  $ php /usr/share/php/composer.phar --working-dir=/usr/share/php \
    dump-autoload -o

to update the classmap for autoloading.

4. When packaging projects like iRony or Roundcube which may use
composer, use the composer.json file as a human readable source of
dependency definitions and create a symlink for the vendor directory:

  <project-dir>/vendor -> /usr/share/php/vendor

That way, developers can keep on using composer.json to define
dependencies and can use composer to install them for their local
project-related development environment and when distributed with the
php-composer distribution packages, autoloading still works as expected.

Kind regards,
Thomas


More information about the devel mailing list