'Laravel Sail : Changes to php.ini not taking effect

What is the correct way of updating php.ini for Laravel Sail?

I've run phpinfo() and it shows /etc/php/8.1/cli/php.ini as "Loaded Configuration File" and /etc/php/8.1/cli/conf.d/99-sail.ini as one of the "additional .ini files parsed".

Any changes to /etc/php/8.1/cli/php.ini do not show in phpinfo(). Also tried copying this to /etc/php/8.1/cli/conf.d/99-sail.ini (with non-default values) but these do not show up either.

Also tried /etc/php/8.1/apache2/php.ini.

Running on Windows 10 with WSL2.

Tried stopping Sail and also closing and reopening all the WSL2 (Ubuntu) windows and rerunning Sail.

What am I missing? Many thanks for a kind soul who can help.



Solution 1:[1]

https://laravel.com/docs/9.x/sail#sail-customization

sail artisan sail:publish

And then you can customize php.ini in /docker directory and rebuild your image with new params.

Solution 2:[2]

This is most likely because php.ini is only copied during docker-compose build. So you could modify it and build your image again. However I would opt to map the php.ini file through a volume from the host to the container in docker-compose.yml.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user18334647
Solution 2 online Thomas