Issues with MAMP 7.0 and PHP 8.3.8

I am an avid user of MAMP, I appreciate the simplicity of their solution and the few resources it requires compared to other development solutions, such as Docker-based solutions or Vagrant Boxes.

So I was very happy to see that version 7.0 covered all Drupal 11 dependencies:

  • PHP 8.3
  • MySQL 8.0.35

However, when I did my first tests, the application was very unstable and I was not able to select PHP 8.3. I also had some issues with MySQL 8.0 encoding (collation) which was not compatible with our production server.

PHP

Here is what I had to do to be able to use PHP 8.3 on MAMP 7.0.

php8.3.8.fcgi file

The following file was missing "/Applications/MAMP/fcgi-bin/php8.3.8.fcgi". I had to create the file based on version 8.2 and modify the versions from 8.2 to 8.3. Then Apache opened with PHP 8.3.

php.ini file

I also had to change includes path in php.ini files (like /Applications/MAMP/bin/php/php8.3.8/conf/php.ini) because PHP 8.2 was sometimes used rather than 8.3.

Update: this step doesn't seem to be required anymore with most recent versions of MAMP coming with PHP 8.3.9.

Apache

Some of our sites using rewrite rules were returning 404 errors (The requested URL was not found on this server.) with the new version of MAMP. This was the case for all our Drupal 10 sites.

By default, the rewrite_module module is not loaded in Apache with MAMP 7.0. To reactivate it, you must reactivate a line in the MAMP/conf/apache/httpd.conf file by removing the # at the beginning of the line:

#LoadModule rewrite_module modules/mod_rewrite.so

becomes :

LoadModule rewrite_module modules/mod_rewrite.so

MySQL 8

In order to maintain compatibility with our server which uses an older version of MariaDB, I forced the default table parameters to use compatible values.

However, these modifications are temporary and will have to be removed when our server also has a version compatible with the latest collation options.

my.cnf file

I had to create the conf/my.cnf file and enter:

[mysqld]
max_allowed_packet = 64M
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci

MySQL variables

In MySQL I ran this to make importing and exporting easier with MySQL 5.

SET PERSIST default_collation_for_utf8mb4='utf8mb4_general_ci';
SET default_collation_for_utf8mb4 = "utf8mb4_general_ci";
SHOW VARIABLES LIKE 'default_collation_for_utf8mb4'

Alternative option with Drupal

In the Drupal settings.php file, we can force the collation to be compatible with our server:

'collation' => 'utf8mb4_general_ci'

I could also have used this method instead of the previous MySQL settings overrides to achieve compatibility with both servers.