简体   繁体   English

如何更改Laravel Artisan CLI PHP版本?

[英]How can I change the Laravel Artisan CLI PHP version?

I posted a question about clearing the cache here the problem was I can't clear cache after editing the .env file. 我在此处发布了有关清除缓存的问题,问题是在编辑.env文件后无法清除缓存。 That is still my real problem. 那仍然是我真正的问题。 (I can't reset the server and I cant use artisan cmds) (我无法重置服务器,也无法使用Artisan cmds)

But this problem needs to be solved before I can solve that one: 但是这个问题需要解决,然后我才能解决:

I cannot run artisan commands. 我无法运行工匠命令。 I have a shared hosting account where my environment PHP version is 7.14 the PHP artisan CLI is using the default PHP 5.4 so I cannot do: php artisan cache:clear etc 我有一个共享的托管帐户,我的环境PHP版本是7.14,PHP artisan CLI使用默认的PHP 5.4,所以我不能这样做:php artisan cache:clear等

I have tried things like 我已经尝试过类似的东西

    $exitCode = Artisan::call('config:cache');

And... 和...

    $process = new Process('/opt/php71/lib artisan config:cache');
    $process->run();

Keep in mind that my application works fine, and PHP version is 7.14 according to PHPINFO. 请记住,我的应用程序运行良好,根据PHPINFO,PHP版本为7.14。

So how can I either get Laravel to clear its cache another way or get artisan to run using a specific PHP version? 那么,如何才能使Laravel以另一种方式清除其缓存,或者如何使工匠使用特定的PHP版本运行?

where my environment PHP version is 7.14 the PHP artisan CLI is using the default PHP 5.4 我的环境PHP版本是7.14,PHP artisan CLI使用默认的PHP 5.4

No, artisan will use whatever version your environment is set to run – the shebang looks like this: 不,工匠将使用您的环境设置为可以运行的任何版本– shebang看起来像这样:

#!/usr/bin/env php

And if you're calling it like php artisan ... then the shebang isn't even used. 而且,如果您像php artisan ...这样称呼它php artisan ...那么什邦甚至都不会被使用。 In either case, you should adjust your path so that PHP 7.1 is called when you run php (ie the directory containing PHP 7.1 should come before the one containing 5.4) and it will work fine. 无论哪种情况,您都应该调整路径,以便在运行php时调用PHP 7.1(即,包含PHP 7.1的目录应位于包含5.4的目录之前),并且它将正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM