是的,你可以运行一个PHP包装器的composer php。 所有Composer源代码都可以在Phar文件中find,所以可以将其解压缩,然后在设置InputInterface以replaceComposer,并希望通过命令行传入命令后运行它。
如果你像这样设置你的目录结构:
./project ./project/composer.json ./project/composer.lock ./project/webroot/composerExtractor.php ./project/var/
把下面的代码放到composerExtractor.php中,然后从网页浏览器运行它,Composer应该把所有的库下载到:
./project/vendors/
以及在该目录中生成类加载器文件。
composerExtractor.php
<?php 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); ?>
虽然这是可能的,但这不是一个好主意,但是如果你不能使用一个给你ssh访问权限的主机,可能是必要的。
我强烈build议您至less为自己或您的办公室获取一个静态IP地址,然后限制访问您自己的IP,以及在服务器上运行该脚本后可能会删除该脚本,以防止意外重新运行。