Hi @pefremidis
If I Google your error I think you are running another PHP version. https://support.bedigit.com/help-center/articles/2/11/28/laravel-parse-error-syntax-error-unexpected-t-class-expecting-t-string-or-t-variable
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello, I uploaded one of my projects to a server and I'm using task scheduling in it. I added the cronjob as the documentation says but it seems that something is wrong with the artisan command.
PHP Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in .../artisan on line 31
I am using Laravel Framework 5.7.28 and PHP 7.3.8
Locally on my machine, everything works as expected!
This can happen on servers managed with software like cPanel. Multiple versions of PHP are installed to allow different PHP versions on a per site basis. So even though phpinfo() (FPM) is on 7.x, the command line (CLI) is not necessarily the same version.
As a work around you can find out where the proper PHP 7.x CLI binary is and directly call that instead of the bash alias.
Please or to participate in this conversation.