Created
July 16, 2018 23:08
-
-
Save james2doyle/1134f3bc0acacdfc158cc5a8941035de to your computer and use it in GitHub Desktop.
Run composer from within a PHP script calling the binary programmatically
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"require-dev": { | |
"symfony/console": "dev-master", | |
"composer/composer": "dev-master" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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."; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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>