How does one add PHP extensions to the docker-compose.yml configuration that comes with Laravel Sail?

Viewed 1570

I created a new Laravel 8 project, which comes with Laravel Sail, a pre-configured Docker environment. It works well, until I need to use a PHP extension.

The Laravel Sail documentation does not appear to mention anything about PHP extensions, which is a significant problem. Any non-trivial PHP site has to use several PHP extensions. Without the ability to add PHP extensions, Laravel Sail (or any other PHP environment) is more or less useless.

There's a Dockerfile and a php.ini in vendor/laravel/sail/runtimes/8.0/. I could copy those files out of vendor and into my own project's code, and hack the docker-compose.yml to point to my versions of those files. However, if I do that, I'll lose any future fixes or improvements that the Laravel Sail people make to those files.

I'm aware of the sail artisan sail:publish command that they mention at the end of the Laravel Sail documentation (https://laravel.com/docs/8.x/sail#sail-customization). It seems to just do what I mentioned above: copies the third-party code into my project, and now suddenly this end-user website is responsible for maintaining its own copy of Laravel Sail.

Surely there's an idiomatic way to add PHP extensions in Laravel Sail, without re-implementing a fork of Laravel Sail in my site's code?

0 Answers
Related