Install Composer Dependancies from PHP script

Solution:

Composer works just as well as a dependency as it does CLI. The Composer CLI is one implementation of what the composer library is designed to do.

Composer Implementation

The application itself bootstraps composer through the factory class.

Factory::create(IOInterface $io, $config = null, $disablePlugins = false);

The composer install command begins by boostrapping an installer

Installer::create(IOInterface $io, Composer $composer);

From there it sets some run time variables whether declared or default and goes into the Installer::run() method.

See the InstallCommand class for more details on how to do an install.

Areas of Interest

Majority of what you should be working with to achieve your goals is implementing a repository for your packages. You may want to look into ArrayRepository and the variations of the installed repositories to guide your implementation. Once you have a repository you can tell composer about your packages.

Installer::setAdditionalInstalledRepository(RepositoryInterface $repo)

Noteworthy Projects

Metadata Browsers

  • Packagist – uses composer extensively for all it provides
  • Wpackagist – similar to packagist while providing pseudo data for a repository
  • Satis – uses composer to generate a package repository similar to the above examples

Installers