Skip to content

Instantly share code, notes, and snippets.

@dmouse
Last active October 19, 2021 20:04
Show Gist options
  • Save dmouse/7532532 to your computer and use it in GitHub Desktop.
Save dmouse/7532532 to your computer and use it in GitHub Desktop.
Run composer command from php script, controller, web,
{
"name": "hechoendrupal/composer-ui",
"description": "Composer UI",
"minimum-stability": "dev",
"authors": [
{
"name": "David Flore",
"email": "[email protected]"
}
],
"require": {
"composer/composer": "1.0.0-alpha7"
}
}
<?php
use Composer\Factory;
use Composer\IO\ConsoleIO;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Helper\HelperSet;
use Symfony\Component\Console\Output\ConsoleOutput;
use Composer\Command\UpdateCommand;
include __DIR__ . '/vendor/autoload.php';
$input = new ArgvInput(array());
$output = new ConsoleOutput();
$helper = new HelperSet();
$io = new ConsoleIO($input,$output,$helper);
$composer = Factory::create($io);
$update = new UpdateCommand();
$update->setComposer($composer);
$update->run($input,$output);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment