tito10047 / symfony-bundle-maker
Composer plugin that generates a Symfony bundle following the official best practices
Package info
github.com/tito10047/symfony-bundle-maker
Type:composer-plugin
pkg:composer/tito10047/symfony-bundle-maker
Requires
- php: >=8.2
- composer-plugin-api: ^2.6
Requires (Dev)
- composer/composer: ^2.6
- friendsofphp/php-cs-fixer: ^3.92
- phpstan/phpstan: ^2.1
- phpstan/phpstan-phpunit: ^2.0
- phpstan/phpstan-strict-rules: ^2.0
- phpunit/phpunit: ^11.5
- symfony/config: ^7.4 || ^8.1
- symfony/dependency-injection: ^7.4 || ^8.1
- symfony/http-kernel: ^7.4 || ^8.1
- symfony/routing: ^7.4 || ^8.1
- symfony/yaml: ^7.4 || ^8.1
Suggests
None
Provides
None
Conflicts
- marc-mabe/php-enum: <4.4
Replaces
None
This package is auto-updated.
Last update: 2026-10-23 07:16:50 UTC
README
Composer plugin for the Symfony Bundle Skeleton.
Right after composer create-project tito10047/symfony-bundle-skeleton, it asks a few questions and
generates a bundle that follows the bundle best practices,
for Symfony 7.4 LTS and 8.1+ (^7.4.17 || ^8.1.5). It then installs the bundle dependencies with a single
composer update and removes itself.
Features
- Derives every name from the package name:
acme/blog-bundlegives the namespaceAcme\BlogBundle, the classAcmeBlogBundle, the extension aliasacme_blog, the translation domain and Twig namespaceAcmeBlog. - Generates the bundle class (
AbstractBundle) and explicit service definitions, in PHP, PHP array or YAML format. - Generates every file the best practices ask for:
README.mdwith the standard installation instructions,docs/index.md,LICENSE(full text of the chosen license),CHANGELOG.md,.gitattributes,.gitignoreand.editorconfig. - Generates a working example (a greeter service, its interface and the exceptions of the bundle) and a PHPUnit test suite with a test kernel, fully covered and failing on deprecations caused by the bundle.
- Optional features, each with its tests and documentation, working alone or together: a controller with its
Twig template, translations, public assets and a Stimulus controller, an invokable console command loaded lazily,
a
kernel.responseevent listener enabled through the configuration, and a Doctrine ORM entity mapped in XML, registered when the application uses the ORM. - Writes a complete
composer.jsonand installs the dependencies in onecomposer update. - Runs without interaction, every answer can be preset with an environment variable.
Optional features
Each feature is a question of the assistant, and a BUNDLE_MAKER_<FEATURE> environment variable:
| Feature | Variable | Default | Generates |
|---|---|---|---|
| Semantic configuration | BUNDLE_MAKER_CONFIG |
yes | config/definition.php, its documentation and tests |
| Controller | BUNDLE_MAKER_CONTROLLERS |
no | an invokable controller, its route (config/routes.*, imported by applications) and its functional test |
| Twig template | BUNDLE_MAKER_TWIG |
yes with a controller | templates/hello.html.twig (@AcmeBlog namespace, no layout), rendered by the controller |
| Translations | BUNDLE_MAKER_TRANSLATIONS |
no | translations/AcmeBlog.en.xlf, in the domain of the bundle, used by the template |
| Console command | BUNDLE_MAKER_COMMAND |
no | an invokable command (acme-blog:hello), loaded lazily, and its tests |
| Event listener | BUNDLE_MAKER_EVENT_LISTENER |
no | a kernel.response listener adding a greeting header, enabled by the greeting_header option (requires the semantic configuration), and its tests |
| Doctrine entity | BUNDLE_MAKER_DOCTRINE |
no | an entity mapped in XML (config/doctrine/), registered when the application uses the ORM (with a model_manager_name option), and its tests on SQLite |
| Public assets | BUNDLE_MAKER_PUBLIC_ASSETS |
no | a stylesheet in public/, installed with assets:install, for applications to link in their layout |
| Symfony UX | BUNDLE_MAKER_UX |
no | a Stimulus controller (assets/package.json, assets/src/) exposed to AssetMapper, used by the template |
| PHPStan | BUNDLE_MAKER_PHPSTAN |
yes | phpstan.dist.neon (level 8, with the Symfony, PHPUnit and Doctrine extensions of the bundle) |
| PHP-CS-Fixer | BUNDLE_MAKER_CS_FIXER |
yes | .php-cs-fixer.dist.php (@Symfony and @Symfony:risky, as Symfony itself) |
| Rector | BUNDLE_MAKER_RECTOR |
yes | rector.php, a local tool (composer rector), neither part of composer qa nor of the CI |
| GitHub Actions | BUNDLE_MAKER_CI |
yes | a CI workflow testing every supported PHP and Symfony version, and Dependabot |
Requirements
PHP 8.2+ and Composer 2.6+. Composer 2.6 is the first version compatible with Symfony 7, which the test suite of the plugin loads together with Composer: older versions are not tested.
Usage without interaction
Every answer can be preset with a BUNDLE_MAKER_* environment variable, which is especially useful
in CI or scripts:
$ BUNDLE_MAKER_NAME=acme/blog-bundle BUNDLE_MAKER_AUTHOR_NAME="Jane Doe" BUNDLE_MAKER_CONFIG_FORMAT=yaml BUNDLE_MAKER_ALL=1 \ composer create-project tito10047/symfony-bundle-skeleton blog-bundle --no-interaction
| Variable | Value |
|---|---|
BUNDLE_MAKER_NAME |
Composer package name, e.g. acme/blog-bundle |
BUNDLE_MAKER_DESCRIPTION |
package description (asked without default in interactive mode) |
BUNDLE_MAKER_AUTHOR_NAME, BUNDLE_MAKER_AUTHOR_EMAIL |
author (defaults to your Git configuration; none omits the email) |
BUNDLE_MAKER_LICENSE |
MIT (default), Apache-2.0, BSD-2-Clause, BSD-3-Clause, GPL-3.0-or-later, LGPL-3.0-or-later, MPL-2.0, proprietary |
BUNDLE_MAKER_CONFIG_FORMAT |
php (default), php-array or yaml |
BUNDLE_MAKER_ALL |
1 enables every feature, 0 disables them all |
BUNDLE_MAKER_<FEATURE> |
1 or 0 for a single feature, e.g. BUNDLE_MAKER_CONFIG=0 |
In interactive mode, presets become the proposed default answers. Every preset is
validated before the first question: an unknown BUNDLE_MAKER_* variable is an error. A
feature is not asked when a feature it requires is disabled. Without interaction, enabling a
feature whose required feature is disabled is an error too (e.g. BUNDLE_MAKER_EVENT_LISTENER=1
with BUNDLE_MAKER_CONFIG=0); in interactive mode, the required feature is asked first.
Running the assistant again
The assistant runs on post-create-project-cmd, also with --no-dev: the skeleton
requires the plugin in require. It does not run when create-project is given
--no-plugins, nor with --no-install, as the plugin is not installed then. If
something fails before the dependencies are installed, the skeleton is left as is. In these cases, install the
dependencies of the skeleton if needed and run the assistant again:
$ composer install $ composer run-script post-create-project-cmd
Installing the dependencies of the bundle
The assistant installs the dependencies of the bundle with one composer update, in the
same process, with the plugins of the bundle (e.g. phpstan/extension-installer). The
verbosity of create-project applies to it, but not its other options: use the environment
variables Composer reads instead, e.g. COMPOSER_IGNORE_PLATFORM_REQ=ext-intl,
COMPOSER_IGNORE_PLATFORM_REQS=1 or COMPOSER_NO_AUDIT=1. If the update fails, fix the
issue and run composer update in the bundle directory.
Contributing
See CONTRIBUTING.md for the architecture, how to add a feature, and the test workflow.
Credits
Based on yceruto/bundle-skeleton and yceruto/bundle-flex by Yonel Ceruto.
License
This software is published under the MIT License