Identify the correct PHP version

If you have more than 1 PHP version, you need to make sure you change the correct php.ini

1) Check the current active PHP version

$ which php
/opt/homebrew/opt/php@8.3/bin/php

2) If this is the correct version, please proceed to the next section.

3) Check what other versions are available.

$ cd /opt/homebrew/opt/php@ <tab>
php@7.4@  php@8.0@  php@8.1@  php@8.2@  php@8.3@

4) Locate the version you need. For example:

/opt/homebrew/opt/php@8.1/bin/php

Locate the correct PHP.ini

1) Use the PHP executable from the full path, and run the following command.

$ /opt/homebrew/opt/php@8.1/bin/php --ini
Configuration File (php.ini) Path: /opt/homebrew/etc/php/8.1
Loaded Configuration File:         /opt/homebrew/etc/php/8.1/php.ini
Scan for additional .ini files in: /opt/homebrew/etc/php/8.1/conf.d
Additional .ini files parsed:      /opt/homebrew/etc/php/8.1/conf.d/ext-opcache.ini

$ /opt/homebrew/opt/php@8.3/bin/php --ini
Configuration File (php.ini) Path: /opt/homebrew/etc/php/8.3
Loaded Configuration File:         /opt/homebrew/etc/php/8.3/php.ini
Scan for additional .ini files in: /opt/homebrew/etc/php/8.3/conf.d
Additional .ini files parsed:      /opt/homebrew/etc/php/8.3/conf.d/ext-opcache.ini

2) Get the php.ini file path from the output above.

3) Edit and save the configuration file.

4) Reload the corresponding php version via Homebrew.

$ brew services restart php@8.1