Skip to content

Instantly share code, notes, and snippets.

@james2doyle
Created July 16, 2018 23:08
Show Gist options
  • Save james2doyle/1134f3bc0acacdfc158cc5a8941035de to your computer and use it in GitHub Desktop.
Save james2doyle/1134f3bc0acacdfc158cc5a8941035de to your computer and use it in GitHub Desktop.
Run composer from within a PHP script calling the binary programmatically
{
"require-dev": {
"symfony/console": "dev-master",
"composer/composer": "dev-master"
}
}
<?php
require 'vendor/autoload.php' // require composer dependencies
use Composer\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;
// Composer\Factory::getHomeDir() method
// needs COMPOSER_HOME environment variable set
putenv('COMPOSER_HOME=' . __DIR__ . '/vendor/bin/composer');
// call `composer install` command programmatically
$input = new ArrayInput(array('command' => 'install'))
$application = new Application();
$application->setAutoExit(false); // prevent `$application->run` method from exitting the script
$application->run();
echo "Done.";
@haytik
Copy link

haytik commented May 8, 2023



rdf:RDF
<cc:Work
rdf:about="">
dc:formatimage/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
dc:title</dc:title>
</cc:Work>
</rdf:RDF>











































































































































































































































































































































Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment