Search code examples
phplaravelcpanellaravel-artisan

Parse error in Artisan after create cron job


I got this error in error_log after create cron job on cpanel.

PHP Parse error: syntax error, unexpected T_CLASS, expecting T_STRING or T_VARIABLE or '$' in /home/kardenoc/Smartflyer/artisan on line 33

this is the line mentioned:

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

I'm using php 7.2(choose php 7.2 on cpanel) and laravel 6. whole process is working expect this cron job.


Solution

  • I think the php command in the cPanel is using an older version.

    The quick solution for you is to use the php7.2 command. E.g. put this in the cron job:

    php7.2 artisan schedule:run >> /dev/null 2>&1