Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

postitief's avatar

PHP artisan fails, php cli version issue

Hello,

I'm not sure how to put in the right title. But I'm running Laravel on a VPS with Plesk and has default php 5.4.16 on the CLI, however the site itself is running on PHP 7.1

No when I want to run php artisan, I need to do the following:

$ /opt/plesk/php/7.1/bin/php artisan

In this way I can run any version of php on the CLI. Running php artisan this way is also fine.

But when I run composer install, I'm getting an error:

$ /opt/plesk/php/7.1/bin/php composer.phar install

Output:

Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating autoload files
> php artisan clear-compiled
PHP Parse error:  syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /var/www/vhosts/domain/httpdocs/artisan on line 31
Script php artisan clear-compiled handling the post-install-cmd event returned with error code 255

I think it is a php cli version issue. Does anyone has some experience with this?

0 likes
5 replies
m1guelpiedrafita's avatar
Level 3

Can you try to run /opt/plesk/php/7.1/bin/php composer.phar install --no-scripts ?

3 likes
postitief's avatar

@m1guelpiedrafita - That is working fine without any errors.

The composer documentation tells me this about the --no-scripts tag.

| --no-scripts: Skips execution of scripts defined in composer.json.

But what does it really do?

m1guelpiedrafita's avatar

@postitief Laravel makes composer optimize the Laravel application. That option disables it. If artisan is working manually, you can do this running:

php artisan optimize
1 like
Bounoable's avatar

That's because composer will try to run the scripts (php artisan optimize) via the default PHP which points to an old php version that doesn't support the PHP-code from artisan and when you run the script manually, the correct php version is being used (/opt/plesk/php/7.1/bin/php)

1 like

Please or to participate in this conversation.