Debugging a Craft CMS installation on macOS

posted on

The other day, I tried to install Craft CMS 5 on my Macbook, and I had some issues with my setup.

I followed the first two steps in the installation guide, and everything worked fine.

mkdir my-craft-project
cd my-craft-project/

ddev config --project-type=craftcms --docroot=web

After running the next command, I got an error that confused me because it seemed like nothing I could influence.

ddev composer create -y "craftcms/craft"

It looked like composer wasn't installed, but that wasn't true.

PHP Warning: require_once(/tmp/NjIfJa/vendor/autoload.php): Failed to open stream: No such file or directory in /tmp/NjIfJa/bootstrap.php on line 11

I'll spare you the details of my research. What eventually worked was updating Xcode in the App Store and the Command Line Tools inside the System Settings.

Rerunning the command, I got a new error message:

Composer detected issues in your platform: Your Composer dependencies require a PHP version >= 8.2.0. You are running 8.1.27. in…

That was also confusing because running php -v in Terminal showed me I was operating on PHP 8.3.16. Someone on StackOverflow pointed out that I, or actually the person who asked the question, may have a different PHP version running on my Apache server. phpinfo() confirmed that, but it was even lower than the version mentioned in the error message. WHAT!?

I decided to remove PHP completely and reinstall it. I followed a guide on getgrav.org.

brew update
brew upgrade
brew cleanup

brew uninstall --ignore-dependencies php
brew uninstall --force php80 php80-apcu php80-opcache php80-xdebug php80-yaml
brew uninstall --force php@8.0
brew cleanup

rm -Rf /usr/local/etc/php/*

Next I had to install PHP again.

brew tap shivammathur/php
brew install shivammathur/php/php@8.3
brew link --overwrite --force php@8.3

And that's it. After updating my operating system and doing a clean install of PHP, I could finally install Craft CMS.