From 6dbdba4201d334e429559599c6bd73a13366292f Mon Sep 17 00:00:00 2001 From: Daniel Klabbers Date: Thu, 3 Dec 2015 18:29:27 +0100 Subject: [PATCH] run composer install without the need of ssh access --- index.php | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/index.php b/index.php index 626fda5..09e1ca3 100644 --- a/index.php +++ b/index.php @@ -1,5 +1,4 @@ listen(); + $server->listen(); +} elseif (ini_get('allow_url_fopen') || file_exists('scripts/composer.phar')) { + // prevent extracting composer anew if already exists + if (!is_dir('tmp/composer')) { + // attempt to download the latest composer file + if(ini_get('allow_url_fopen')) + { + file_put_contents('https://getcomposer.org/installer', 'scripts/composer.phar'); + } + $composer = new Phar('scripts/composer.phar'); + mkdir('tmp'); + $composer->extractTo('tmp/composer'); + } + // if extraction succeeded, let's run the update command. + if (is_dir('tmp/composer') && file_exists('tmp/composer/vendor/autoload.php')) { + // otherwise composer will run out of memory easily + ini_set('memory_limit', '-1'); + // include the extracted composer libraries + require_once 'tmp/composer/vendor/autoload.php'; + + putenv('COMPOSER_HOME=' . getcwd() . '/tmp/home'); + + // set the input for the composer command + $input = new Symfony\Component\Console\Input\ArrayInput(['command' => 'install', '--no-dev']); + + // run the composer things + $application = new Composer\Console\Application(); + $application->run($input); + } +} else { + throw new Exception('This method of installation is currently unsupported.'); +} \ No newline at end of file