Answers.Body: <p>This has got to be a MAMP bug with Composer.</p>
  <p>I get the same thing trying to install a Laravel application:</p>
  <pre><code>composer create-project --prefer-dist laravel/laravel testproj
  
  ...
  
  &gt; @php -r &quot;file_exists('database/database.sqlite') || touch('database/database.sqlite');&quot;
  ERROR: Invalid syntax. Value expected for '-r'.
  Type &quot;WHERE /?&quot; for usage.
  
  ...
  </code></pre>
  <p>The command works fine when you execute it directly from the CLI instead of it being executed from a script in the composer.json file.</p>
  <p>The same thing happens with the more simple test case of this in composer.json:</p>
  <pre><code>&quot;scripts&quot;: {
      &quot;pre-update-cmd&quot;: [
        &quot;@php -r \&quot;echo 'hi';\&quot;&quot;
      ]
    }
  </code></pre>
  <p>And just running <code>composer update</code>.</p>
  <p>I also tested WAMP and native PHP installed on Windows and couldn't reproduce it there.</p>
  <p>I did a bunch of internet and MAMP forums searching for that particular error, but no luck. And it doesn’t appear MAMP has a public bug tracker, so I can’t tell if it’s an issue they’re aware of or not.</p>
  <p>Looks like you can submit a <a href="https://support.mamp.info/index.php?a=add&amp;category=1" rel="nofollow noreferrer">bug report here</a>, though.</p>
  <p>At any rate, I’d probably recommend swapping over to DDEV. It’s what we generally recommend and works great on Windows, Linux, and macOS, and the starter project was written with it in mind.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-10-18T23:11:08.570Z
Answers.LastActivityDate: 2024-10-18T23:11:08.570Z
Answers.UserDisplayName: Brad Bell
Body: <p>I am trying to install Craft 5, but the Composer-based installation is throwing several errors at the end.  These errors appear after all packages seem to be successfully downloaded and installed by Composer.  The install command I ran:</p>
  <pre><code>composer create-project craftcms/craft myprojectname
  </code></pre>
  <p>And the tail end of the output where the errors occur:</p>
  <pre><code>&gt; @php -r &quot;file_exists('.env') || copy('.env.example.dev', '.env');&quot;
  ERROR: Invalid syntax. Value expected for '-r'.
  Type &quot;WHERE /?&quot; for usage.
  &gt; @php -r &quot;unlink('composer.json');&quot;
  ERROR: Invalid syntax. Value expected for '-r'.
  Type &quot;WHERE /?&quot; for usage.
  &gt; @php -r &quot;rename('composer.json.default', 'composer.json');&quot;
  ERROR: Invalid syntax. Value expected for '-r'.
  Type &quot;WHERE /?&quot; for usage.
  &gt; @php craft install
  Generating an application ID ... done (CraftCMS--6176f2a9-603b-44d9-877c-7dd0c8da5b)
  Generating a security key ... done (FTj7BEzuRcOIEf8XKEWxUmTwm8C64)
  
  Invalid options:
      --username: Username cannot be blank.
      --email: Email cannot be blank.
      --password: New Password should contain at least 6 characters.
      --site-name: Name cannot be blank.
      --language: Language cannot be blank.
  Script @php craft install handling the post-create-project-cmd event returned with error code 64
  </code></pre>
  <p>I'm using PHP 8.3.7 on Windows 11 with MAMP 5.0.6.</p>
  <p>&quot;php -v&quot; returns this:</p>
  <pre><code>PHP 8.3.7 (cli) (built: May 31 2024 15:03:52) (ZTS Visual C++ 2019 x64)
  Copyright (c) The PHP Group
  Zend Engine v4.3.7, Copyright (c) Zend Technologies
  </code></pre>
  <p>Given that I copied the install command right off the Craft &quot;Getting Started&quot; web page, and 8.3 is a supported php version, I'm not sure why I'm running into trouble right off the bat.</p>
  
Tags: <php><craft5>
Title: PHP invalid syntax error during Craft 5 Installation
ThreadText: # PHP invalid syntax error during Craft 5 Installation
  
  (Asked by: username_0 on 2024-10-18)
  
  I am trying to install Craft 5, but the Composer-based installation is throwing several errors at the end. These errors appear after all packages seem to be successfully downloaded and installed by Composer. The install command I ran:
  
  ```
  composer create-project craftcms/craft myprojectname
  
  ```
  
  And the tail end of the output where the errors occur:
  
  ```
  > @php -r "file_exists('.env') || copy('.env.example.dev', '.env');"
  ERROR: Invalid syntax. Value expected for '-r'.
  Type "WHERE /?" for usage.
  > @php -r "unlink('composer.json');"
  ERROR: Invalid syntax. Value expected for '-r'.
  Type "WHERE /?" for usage.
  > @php -r "rename('composer.json.default', 'composer.json');"
  ERROR: Invalid syntax. Value expected for '-r'.
  Type "WHERE /?" for usage.
  > @php craft install
  Generating an application ID ... done (CraftCMS--6176f2a9-603b-44d9-877c-7dd0c8da5b)
  Generating a security key ... done (FTj7BEzuRcOIEf8XKEWxUmTwm8C64)
  
  Invalid options:
      --username: Username cannot be blank.
      --email: Email cannot be blank.
      --password: New Password should contain at least 6 characters.
      --site-name: Name cannot be blank.
      --language: Language cannot be blank.
  Script @php craft install handling the post-create-project-cmd event returned with error code 64
  
  ```
  
  I'm using PHP 8.3.7 on Windows 11 with MAMP 5.0.6.
  
  "php -v" returns this:
  
  ```
  PHP 8.3.7 (cli) (built: May 31 2024 15:03:52) (ZTS Visual C++ 2019 x64)
  Copyright (c) The PHP Group
  Zend Engine v4.3.7, Copyright (c) Zend Technologies
  
  ```
  
  Given that I copied the install command right off the Craft "Getting Started" web page, and 8.3 is a supported php version, I'm not sure why I'm running into trouble right off the bat.
  
  **Tags:** php, craft5
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-10-18. Score: 3
  
  This has got to be a MAMP bug with Composer.
  
  I get the same thing trying to install a Laravel application:
  
  ```
  composer create-project --prefer-dist laravel/laravel testproj
  
  ...
  
  > @php -r "file_exists('database/database.sqlite') || touch('database/database.sqlite');"
  ERROR: Invalid syntax. Value expected for '-r'.
  Type "WHERE /?" for usage.
  
  ...
  
  ```
  
  The command works fine when you execute it directly from the CLI instead of it being executed from a script in the composer.json file.
  
  The same thing happens with the more simple test case of this in composer.json:
  
  ```
  "scripts": {
      "pre-update-cmd": [
        "@php -r \"echo 'hi';\""
      ]
    }
  
  ```
  
  And just running `composer update`.
  
  I also tested WAMP and native PHP installed on Windows and couldn't reproduce it there.
  
  I did a bunch of internet and MAMP forums searching for that particular error, but no luck. And it doesn’t appear MAMP has a public bug tracker, so I can’t tell if it’s an issue they’re aware of or not.
  
  Looks like you can submit a [bug report here](https://support.mamp.info/index.php?a=add&category=1), though.
  
  At any rate, I’d probably recommend swapping over to DDEV. It’s what we generally recommend and works great on Windows, Linux, and macOS, and the starter project was written with it in mind.
  
  
  ---
  
  