<p>You're running an outdated version of PHP on your command line. Depending on your setup, your terminal may use an OS-provided version of PHP which isn't up to date. The error comes from <a href="https://github.com/craftcms/plugin-installer/blob/master/src/Installer.php#L471" rel="nofollow noreferrer">this line</a>:</p>
<pre class="lang-php prettyprint-override"><code>private function _path(string $vendorDir, string $cwd, string $path): string
</code></pre>
<p>The parser throws this error because of the return type declaration (<code>: string</code>) after the function signature. This feature was only <a href="https://www.php.net/manual/en/migration70.new-features.php" rel="nofollow noreferrer">introduced in PHP 7.0</a>, so to get this error you have to be running an older version than that. To find out which version of PHP you're running and where the binary is on your machine, use <code>php -v</code> and <code>which php</code>. You can also check which PHP binary Composer is running with <code>composer -vvv about</code>.</p>
<p>To fix this, install PHP 8.1 or 8.0 on your machine and make sure it comes before the current version in your <code>$PATH</code> so Composer can use it.</p>

CC BY-SA 4.0
2022-02-03T16:04:20.027Z
Hi Moritz, thanks for your help.  I think that's it, looks like the Mac itself is running 5.6.  Ok, I'll try and get that updated.
Mark
CC BY-SA 4.0
2022-02-03T14:52:17.127Z
2022-02-03T14:52:17.127Z
MoritzLost
<p>I'm getting an error with almost every Craft project I set up when I try and run any composer command:</p>
<pre><code>Parse error: parse error, expecting `';'' or `'{'' in /path-to-my-project/craft/vendor/craftcms/plugin-installer/src/Installer.php on line 471
</code></pre>
<p>This happens with all Craft installations and all composer commands, update, install etc.</p>
<p>We're using a Mac and MAMP</p>
<p>Has anyone seen this before?</p>

<plugins><composer>
Error when running composer commands
# Error when running composer commands

(Asked by: username_0 on 2022-02-03)

I'm getting an error with almost every Craft project I set up when I try and run any composer command:
Parse error: parse error, expecting `';'' or `'{'' in /path-to-my-project/craft/vendor/craftcms/plugin-installer/src/Installer.php on line 471

This happens with all Craft installations and all composer commands, update, install etc.
We're using a Mac and MAMP
Has anyone seen this before?

**Tags:** plugins, composer


---

## 1 answers

### Answer by username_1 on 2022-02-03. Score: 3 | Accepted answer

You're running an outdated version of PHP on your command line. Depending on your setup, your terminal may use an OS-provided version of PHP which isn't up to date. The error comes from this line:
private function _path(string $vendorDir, string $cwd, string $path): string

The parser throws this error because of the return type declaration (: string) after the function signature. This feature was only introduced in PHP 7.0, so to get this error you have to be running an older version than that. To find out which version of PHP you're running and where the binary is on your machine, use php -v and which php. You can also check which PHP binary Composer is running with composer -vvv about.
To fix this, install PHP 8.1 or 8.0 on your machine and make sure it comes before the current version in your $PATH so Composer can use it.

> **Comments:**
> **username_0**: Hi Moritz, thanks for your help.  I think that's it, looks like the Mac itself is running 5.6.  Ok, I'll try and get that updated.  

---

