2

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.

1 Answer 1

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, 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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.