Skip to content

Commit

Permalink
adding server-side composer update
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Kouba committed Jul 15, 2016
1 parent 9f1d559 commit 4f9fc04
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions public/composer.php
Expand Up @@ -12,7 +12,6 @@
die('Access Denied - security token not provided');
}


echo '<pre> ______
/ ____/___ ____ ___ ____ ____ ________ _____
/ / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
Expand All @@ -21,23 +20,21 @@
/_/
';

//Configuration
define('ROOT_DIR',realpath('../'));
define('EXTRACT_DIRECTORY', ROOT_DIR. '/storage/composer');
define('HOME_DIRECTORY', ROOT_DIR. '/storage/composer/home');
define('COMPOSER_INITED', file_exists(ROOT_DIR.'/vendor'));

set_time_limit(100);
ini_set('memory_limit',-1); //could be forbidden on server

if (!getenv('HOME') && !getenv('COMPOSER_HOME')) {
putenv("COMPOSER_HOME=".HOME_DIRECTORY);
}
if (!getenv('HOME') && !getenv('COMPOSER_HOME')) { putenv("COMPOSER_HOME=".HOME_DIRECTORY); }


//Extracting Composer library
if (file_exists(EXTRACT_DIRECTORY.'/vendor/autoload.php') == true) {
echo "Extracted autoload already exists. Skipping phar extraction as presumably it's already extracted.\n";
}
else{
} else {
$composerPhar = new Phar("../composer.phar");
//php.ini setting phar.readonly must be set to 0
$composerPhar->extractTo(EXTRACT_DIRECTORY);
Expand All @@ -46,8 +43,6 @@
// change directory to root
chdir(ROOT_DIR);



//This requires the phar to have been extracted successfully.
require_once (EXTRACT_DIRECTORY.'/vendor/autoload.php');

Expand All @@ -65,9 +60,26 @@
}
$input = new ArrayInput($args);


//Create the application and run it with the commands
$application = new Application();
$application->setAutoExit(false);
$application->run($input);
$application->setCatchExceptions(false);
try {
//Running commdand php.ini allow_url_fopen=1
$exitCode = $application->run($input);
} catch (\Exception $e) {
$exitCode = 1;
echo 'Error: '.$e->getMessage()."\n";
}


echo "Done</pre>";
//Result message
if($exitCode ==0) {
echo "Successfully Done";
} elseif($exitCode ==2) {
echo "Composer Failed due to dependency solving error";
} else {
echo "Composer Failed due to generic error";
}
die('</pre>');

0 comments on commit 4f9fc04

Please sign in to comment.