栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

在浏览器中使用PHP脚本运行作曲家

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

在浏览器中使用PHP脚本运行作曲家

是的,您可以使用一个小的PHP包装器来运行Composer。Phar文件中提供了所有Composer源代码,因此可以提取该源代码,然后在设置InputInterface替换Composer后运行它,并期望通过命令行传递命令。

如果您这样设置目录结构:

./project  ./project/composer.json./project/composer.lock./project/webroot/composerExtractor.php  ./project/var/

将下面的代码放入composerExtractor.php中,然后从Web浏览器中运行它,Composer应该将所有库下载到:

./project/vendors/

以及在该目录中生成类加载器文件。

composerExtractor.php

<?phpdefine('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 classesuse ComposerConsoleApplication;use ComposerCommandUpdateCommand;use SymfonyComponentConsoleInputArrayInput;// change out of the webroot so that the vendors file is not created in// a place that will be visible to the intahwebzchdir('../');//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访问权限的主机,则可能有必要。

我强烈建议至少为您自己或您的办公室获取一个静态IP地址,然后限制对您自己IP的访问,以及可能在服务器上运行该脚本后删除此脚本,以防止再次意外运行。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/430485.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号