klke/docker-compose-generator-bundle
A Symfony bundle that generates Docker Compose configuration for PHP projects, helping you define services and scaffold container-based development environments from application config. It aims to simplify and standardize local Docker setups and reduce hand-written YAML.
ServiceProvider, no config/*.php publish tag, no Artisan command. Composer will install it, but nothing in Laravel's bootstrap will register or use it. Treat it as a reference implementation or a standalone generator you invoke from a script, not as an artisan-driven tool.vendor/klke/docker-compose-generator-bundle/DependencyInjection/Configuration.php (the real option surface — READMEs on 4-star packages are usually stale) and Resources/config/ (service wiring + any Twig/YAML template used for output). That template is the only thing that determines whether the output is useful to you.bin/ script or Make target) to emit a compose file for a throwaway test topology.config/bundles.php before any command exists. If a bin/console list | grep -i docker returns nothing, it's not registered — that's the first thing to debug, not the last.docker-compose.test.yml with app + mysql + redis, then point .env.testing at the compose service hostnames. Compare that output against laravel/sail — Sail almost certainly already does it, better.require. If it goes in at all, composer require --dev klke/docker-compose-generator-bundle and keep it out of the deployed application.Generate once, commit, then own it. The realistic Laravel pattern is: run the generator (or use its template as a guide), commit the resulting docker-compose.yml, hand-edit it, and stop regenerating. Re-running over a customized file is how you lose an afternoon to a clobbered override.
Wrap generation in a script that refuses to overwrite. [ -f docker-compose.yml ] || php scripts/gen-compose.php inside a make docker-init target, printing a diff if the file already exists. This gives you the convenience once and prevents the clobbering forever.
Prefer the standalone invocation over an in-app integration. A bin/generate-compose PHP script that requires the generator classes directly (bypassing Symfony's Kernel) is far more palatable than dragging Symfony's DI into a Laravel app. You get the compose output without the framework coupling.
Let env vars drive both sides. Keep the generated file using ${DATABASE_URL} and ${REDIS_HOST}-style interpolation so a single .env.testing feeds both Laravel's config/database.php and the compose services. Otherwise the compose file and your config/ drift apart silently.
Name services to match Laravel's config expectations. A service named db means DB_HOST=db reads correctly in config/database.php and survives a MySQL image bump. Names like mysql-primary-1 break the mental model and force you to edit config every time.
CI pipeline pattern:
generate (if absent) → docker compose up -d --wait → migrate → phpunit → docker compose down -v
The --wait and a healthcheck on the DB are the pieces generators rarely give you; add them yourself.
Extend via docker-compose.override.yml, never by forking the template. Healthchecks, init SQL, fixtures, mailhog, Xdebug toggles — all of these are things the generator won't model. An override file upgrades cleanly; a patched Twig template does not.
If you're in a mixed Symfony/Laravel monorepo, run this generator only in the Symfony sub-app's build step and share the resulting compose topology with the Laravel side via a committed .yml. Don't try to run it from the Laravel side.
Treat the generator as a spike, not a standard. Time-box the evaluation to a day: generate a compose file for one non-critical service (a test DB), diff it against what Sail produces, and reject unless it's strictly better. It usually isn't.
symfony/* components pinned by the framework. A bundle requiring a divergent major version can force a composer update resolution fight. If you see conflict errors, that's not a bug in your app — it's the architecture mismatch.php artisan docker:generate, it does not exist. Don't spend an hour looking for it.Configuration.php returning a TreeBuilder), not Laravel-style arrays. Options you set in config/packages/*.yaml have no equivalent in Laravel's config/*.php. Any attempt to "port" the config is a rewrite, not a copy.# generated by klke/... — edits will be lost) the team discovers this late, usually in CI. Add the header yourself, or gate the generator so it can't run over an existing file.3306/volume names. Use COMPOSE_PROJECT_NAME per job and prefer ephemeral volumes.composer require laravel/sail --dev && php artisan sail:install covers 90% of what this package aims at, is first-party, and is already known to your team. The bar for using this instead is a specific gap Sail does not fill — write that gap down before installing.requires the generator, that's a supply-chain decision you didn't make consciously.docker-compose.override.yml and your own fork, not around the bundle's internals.How can I help you explore Laravel packages today?