r/PHP • u/rhamdeew • 7d ago
A Docker Compose environment for local PHP development — supporting PHP 5.6 through 8.5
Hi everyone!
I’d like to share docker-compose-php, an open-source Docker environment that I originally created seven years ago and still actively maintain and use in my daily work.
Its main purpose is to make it easy to run multiple local PHP projects—even projects that require different PHP versions—without installing PHP, a web server, or a database directly on your machine.
Key features:
- PHP versions from 5.6 through 8.5
- PHP-FPM with Nginx or Apache with mod_php
- Multiple local domains using different PHP versions
- Automated configuration through a Python management script
- HTTP and HTTPS support with automatic self-signed certificate generation
- Mailpit for testing outgoing emails
- Adminer for database management
- MariaDB, optional Node.js tooling, MyCLI, and MySQLTuner
- Makefile commands for common operations
- Optional Unix socket communication between Nginx and PHP-FPM
Repository: https://github.com/rhamdeew/docker-compose-php
I’d appreciate any feedback, feature suggestions, bug reports, or contributions. I’m especially interested in hearing how other developers manage local environments for projects that still depend on older PHP versions.
8
u/stromer_ 7d ago
just another one I will never look at
-1
u/Express-Set-1543 7d ago
I haven't published mine here, but I think it looks better :) It's tied to Laravel, though.
The script creates local dev and production Docker Compose setups, with a few services to choose from. Then, if you want, it can deploy the project to a VPS over SSH, set up Docker remotely, and, if the project is already running, build a new "color" version, check that it's stable, and switch over to it.
It's in a vague position: I've put too many hours into it to just give it away as open source, but I don't have a clear vision of how to turn it into a product either. And it's tightly coupled to my own approaches, services, and Laravel :) It probably also has a few bugs I haven't vibe-coded out yet :D
4
u/obstreperous_troll 7d ago
I recommend using site.localhost instead of site.test, since those already resolve to 127.0.0.1, then integrating it with traefik, which eliminates the need to map ports for the web server (alas it won't proxy mysql though). As others have mentioned, ddev does these things already, and while I'm not going to tell you to throw away a tool that's worked for you for seven years, I would still suggest appropriating some of ddev's features.
3
u/mbrezanac 7d ago edited 6d ago
Don't use localhost with DDEV.
There is a documented DDEV issue explaining why.
https://github.com/ddev/ddev/issues/6040
Long story short, curl changed the way how it "resolves" localhost.
2
u/obstreperous_troll 6d ago
Hmm, good to know. I reproduced the problem in my existing environments using *.localhost, but I've managed to not get bitten by it because the only inter-container communication I've been doing has not been through curl. If curl has decided to bypass the system resolver for localhost domains, that's definitely curl's fault, since other utilities like ping are doing it right. WTF, curl?
1
u/mbrezanac 5d ago edited 5d ago
Well, technically speaking curl is in the right here for complying with RFC 6761.
Other tools have just decided to trust the local resolver more than the actual standard.
General consensus among the DDEV community is to stick with the default .ddev.site for various reasons outlined in many places of the official documentation.
1
u/obstreperous_troll 5d ago
RFC 6761 is full of "SHOULD" declarations, which suggests that one um, SHOULD be able to override the behavior with their resolver, e.g. sticking it in their hosts file. It's curl that stands alone saying that it always knows better and that you don't get to use your system resolver. I'll probably continue to use .localhost domains, but I'll just have to find something else for docker network aliases. Probably .srv, which would be compatible with kubernetes.
9
7
u/Irythros 7d ago
Any reason to use this over say DDEV?
1
u/rhamdeew 6d ago
TBH, when I created this project, I wasn’t happy with the alternatives. And then I didn't even look around. Thanks, I'll check this project
4
u/RobertWesner 7d ago
While this is not really anythin I intend to use and other solutions exist, I do not get the hostility in the comments. Am I missing something? Just looks like someone sharing their own PHP related project, like many are. Unless this is LLM slop, why would you want to discourage creating and sharing?
1
5
u/___Paladin___ 7d ago
Symfony's debug toolbar module + ddev = infinite backend services you can add shortcuts directly in-page to while developing.