0

I have run into a problem when trying to upload my Laravel project to my live web server. Everything works perfectly on local server. But, my local server is running PHP 7.2.6, and my host server only supports 7.1 at this time. So, when I try to set up cron jobs for my server to run my Laravel scheduled tasks, I get this error:

Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /home/me/project/artisan on line 31

This line contains:

$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);

And I know the issue has to do with calling Kernel::class, but I am unable to change the PHP version to 7.2 to solve this. So, is there another workaround? My only worry is that even if I took care of this error, that there would be more.

Rwd
  • 34,180
  • 6
  • 64
  • 78
develpr
  • 1,296
  • 4
  • 22
  • 42

1 Answers1

1

The error your getting seems to suggest you're using PHP <=5.4.

The default version of php used by the cli might not be the same version as the one being used for your site.

You can check this by running php -v on the command line to see which version it's using. If it is the wrong version then you should be able to run whereis php to get a list of paths to the different php versions available.

Once you've found the correct version then you can update your cronjob to use the path to the correct php executable e.g.

/path/to/php /home/username/path-to-artisan schedule:run > /dev/null 2>&1
Rwd
  • 34,180
  • 6
  • 64
  • 78