简体   繁体   中英

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. That is still my real problem. (I can't reset the server and I cant use 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

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.

So how can I either get Laravel to clear its cache another way or get artisan to run using a specific PHP version?

where my environment PHP version is 7.14 the PHP artisan CLI is using the default PHP 5.4

No, artisan will use whatever version your environment is set to run – the shebang looks like this:

#!/usr/bin/env php

And if you're calling it like php artisan ... then the shebang isn't even used. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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