php中html在浏览器运行脚本,在浏览器中使用PHP脚本运行composer php

是的,你可以运行一个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,以及在服务器上运行该脚本后可能会删除该脚本,以防止意外重新运行。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值