无需 ssh 访问即可运行 composer 和 laravel(工匠)命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36840315/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 13:40:32  来源:igfitidea点击:

run composer and laravel (artisan) commands without ssh access

phpshelllaravelssh

提问by Frank Provost

I want to test some Laravel applications on my basic shared host.

我想在我的基本共享主机上测试一些 Laravel 应用程序。

Currently I just upload my complete application including the vendor files, however this takes quite long.

目前我只是上传我的完整应用程序,包括供应商文件,但这需要很长时间。

Since I do not have sshaccess to my host I'd like to know whether there's an option to run composer / artisan commands without this.

由于我无法ssh访问我的主机,我想知道是否有一个选项可以在没有这个的情况下运行 composer / artisan 命令。

I found this link: Use Composer without ssh access to server(Second Answer) which describes how to run composer using http://phpshell.sourceforge.net/

我找到了这个链接:Use Composer without ssh access to server(Second Answer) 它描述了如何使用http://phpshell.sourceforge.net/运行 composer

However, I can change folders in the console etc. But I cannot run php commands - I always get internal server error.

但是,我可以在控制台等中更改文件夹。但我无法运行 php 命令 - 我总是收到内部服务器错误。

采纳答案by Alexey Mezenin

Check if your shared hosting provider has consolefeature in their CP which allows to run shell commands. Maybe you'll be able to run commands from there.

检查您的共享主机提供商是否console在其 CP 中具有允许运行 shell 命令的功能。也许您将能够从那里运行命令。

As alternative, you could right your own artisan runner and call artisan commands from the code:

作为替代方案,您可以纠正自己的工匠跑步者并从代码中调用工匠命令

Artisan::call('migrate');

To run composer command from PHP code, use shell_exec:

要从 PHP 代码运行 composer 命令,请使用shell_exec

shell_exec('composer update');