Laravel parse error: syntax error, unexpected T_CLASS, expecting T_STRING in artisan

I checked my php version:

PHP 7.0.27 (cli) (built: Jan 23 2018 09:07:32) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies

Image php Version here

But this is the error that appears when doing cron job

Parse error: syntax error, unexpected T_CLASS, expecting T_STRING or T_VARIABLE or '$' in /path_to_project/artisan on line 31
X-Powered-By: PHP/5.3.29 Content-type: text/html

and I used this to test this code

<?php 
class Foo{}
echo Foo::class;

?>

The output is :Foo

artisan file

#!/usr/bin/env php
<?php
require __DIR__.'/bootstrap/autoload.php';

$app = require_once __DIR__.'/bootstrap/app.php';


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

$status = $kernel->handle(
$input = new Symfony\Component\Console\Input\ArgvInput,
new Symfony\Component\Console\Output\ConsoleOutput
);

$kernel->terminate($input, $status);

exit($status);

I run it like this:

* * * * * php /path_to_project/artisan schedule:run >> /path_to_project/log.txt
* * * * * php-cli -q /path_to_project/artisan  schedule:run >> /path_to_project/log.txt

How do I resolve this error?

1 answer