xxxxxxxxxx
- name: "Composer install"
become: yes
become_user: not_root_user
composer:
command: install
global_command: false
working_dir: /path/to/project
xxxxxxxxxx
<?php
/*
./project
./project/composer.json
./project/composer.lock
./project/webroot/composerExtractor.php
./project/var/
*/
define('EXTRACT_DIRECTORY', "../var/extractedComposer");
if (file_exists(EXTRACT_DIRECTORY.'/vendor/autoload.php') == true) {
echo "Extracted autoload already exists. Skipping phar extraction as presumably it's already extracted.";
}
else{
$composerPhar = new Phar("Composer.phar");
//php.ini setting phar.readonly must be set to 0
$composerPhar->extractTo(EXTRACT_DIRECTORY);
}
//This requires the phar to have been extracted successfully.
require_once (EXTRACT_DIRECTORY.'/vendor/autoload.php');
//Use the Composer classes
use Composer\Console\Application;
use Composer\Command\UpdateCommand;
use Symfony\Component\Console\Input\ArrayInput;
// change out of the webroot so that the vendors file is not created in
// a place that will be visible to the intahwebz
chdir('../');
//Create the commands
$input = new ArrayInput(array('command' => 'update'));
//Create the application and run it with the commands
$application = new Application();
$application->run($input);
?>