How do I execute php with different version through phpbrew

388 Views Asked by At

Currently I am working on a laravel project that uses some cron jobs to process data.

The default php version on this server is 7.0.7. However this project runs on php 5.6.6 through phpbrew.

When I execute a script inside my project folder through laravel artisan, phpinfo() returns php version 5.6.6. When my cron job executes the exact same command it returns version 7.0.7.

Is it possible to say to my cron to use a different php version through phpbrew? How would it look like?

My cron job looks like:

00 12 * * * php /projectfolder/artisan execute:command

1

There are 1 best solutions below

1
On BEST ANSWER

You will need to change your cron to link the absolute path of the php binary you want to use. 00 12 * * * /path/to/bin/that/is/used/by/app/php /projectfolder/artisan execute:command

Also, if this is L5.1 or greater, check out task scheduling https://laravel.com/docs/master/scheduling