1

Installing Craft on MediaTemple. Ran the server check and it came back green except for the memory allocation, which I increased in the PHP.ini file.

Ran the composer install script and it runs fine until:

- Installing craftcms/plugin-installer (1.5.7): Extracting archive
PHP Parse error:  syntax error, unexpected ':', expecting ';' or '{' in /var/www/vhosts/[example].com/beta.[example].com/vendor/craftcms/plugin-installer/src/Installer.php on line 471
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /var/www/vhosts/[example].com/beta.[example].com/vendor/craftcms/plugin-installer/src/Installer.php on line 471

As far as I can see, all the files are there.

All of the advice I can find says upgrade your PHP, but the server already has 7.3.31.

Any guidance much appreciated.

2

The error message tells you that PHP encountered a syntax error while parsing the file Installer.php. Here's the line in question:

private function _path(string $vendorDir, string $cwd, string $path): string

The error message (syntax error, unexpected ':') tells you that PHP doesn't recognize the return type hint. Those were added in PHP 7.0 – so you're definitely using an older version, or you wouldn't be getting that error.

All of the advice I can find says upgrade your PHP, but the server already has 7.3.31.

The likeliest explanation is that the hosting company uses PHP 7.3 for web requests (for example, using PHP-FPM), but has not modified it's terminal / bash environment to use that version. Try running php -v in the terminal (while connected to the server over SSH) to see which version of PHP you're executing. You can also run composer with the -vvv flag to see which version of PHP it's using.

You're likely to see that php in the terminal is linked to an older version of PHP. In this case, you need to find out where the hoster keeps the binary for the current PHP version and execute the installation (and run composer) with that.

By the way, security support for PHP 7.3 will run out in december 2021. If you're starting a new site, you should get started with PHP 8.0.

2
  • You were correct: running php -v returns 5.4.16. Thanks for the help, I never would have found that by myself.
    – Mitrol
    Oct 30 '21 at 13:45
  • @Mitrol Glad this worked for you! It's always annoying when the hoster doesn't consider CLI usage and doesn't synchronize their shell environments with the backend settings. Nowadays I use VPS by DigitalOcean or Hetzner instead, controlled by a server management tool like Laravel Forge. Way more control over your server environment and less annoyances with curious behaviours on shared hosting platforms.
    – MoritzLost
    Oct 31 '21 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.