June 13th, 2013 · php zend framework 2

Execute Composer commands from your PHP application

I'll just leave this here...

Example: Clone ZF2's ZendSkeletonApplication

ZendSkeletonApplication is installed using this composer command line:

php composer.phar create-project -sdev --repository-url="http://packages.zendframework.com" zendframework/skeleton-application /path/to/skeleton-application

The equivalent using Composer source is:

$obj = new \Composer\Command\CreateProjectCommand();
$input = new \Symfony\Component\Console\Input\ArrayInput(array(
    'package'          => 'zendframework/skeleton-application',
    'directory'        => '/path/to/skeleton-application',
    '--stability'      => 'dev',
    '--repository-url' => 'http://packages.zendframework.com',
), $obj->getDefinition());
$output = new \Symfony\Component\Console\Output\ConsoleOutput();
$obj->run($input,$output);