Introducing the Symfony Maker Bundle
November 21, 2017 • Published by Javier Eguiluz
If you've been around the Symfony community for some time, odds are you know and have used the SensioGeneratorBundle. It's a popular bundle (+20 million downloads) that provides console commands to generate boilerplate code, like controllers and entities. It also includes a basic CRUD generator.
Given that SensioGeneratorBundle is starting to show its age and considering the massive simplifications introduced by Symfony 4, we decided to stop evolving that bundle and we've created a new bundle called SymfonyMakerBundle.
SymfonyMakerBundle helps you creating empty commands, controllers, form classes, tests and more so you can forget about the required boilerplate code. It's an alternative to SensioGeneratorBundle for modern Symfony applications and requires using Symfony 3.4 or newer and Symfony Flex.
Of course the end goal is to not have boilerplate code at all in Symfony applications. Symfony 4 made a lot of improvements towards that goal, but you will always have to bootstrap some code, so having a modern, simple and lightweight bundle to do that is nice.
Generating Code with Makers
The usage of the bundle is similar to SensioGeneratorBundle, but the commands
now use the make:
prefix instead of generate:
. In this first version of
the bundle we've implemented the following makers:
1 2 3 4 5 6 7 8 9 10 11 12
$ php bin/console list make
make:command
make:controller
make:entity
make:form
make:functional-test
make:subscriber
make:twig-extension
make:unit-test
make:validator
make:voter
Later we'll add more commands, including some interactive makers to generate a Doctrine entity asking for its properties, to generate a form based on a Doctrine entity, etc.
How Can You Help Us
The best way to help us is to test it in your own applications and report any issue or uncovered edge case. You can also review the code to improve it using any of the modern PHP 7.1 features.
If you have ideas for new features or maker commands, please open an issue to discuss about them instead of sending a pull request.
Finally, it'd be great if you could give this project a GitHub Star because that motivates us a lot.
Help the Symfony project!
As with any Open-Source project, contributing code or documentation is the most common way to help, but we also have a wide range of sponsoring opportunities.
Comments are closed.
To ensure that comments stay relevant, they are closed for old posts.
SensioGeneratorBundle used to generate many files (eg a whole empty bundle, controllers with templates and routing configuration, entities with repositories and yaml configuration, etc), while MakerBundle only seems to generate a class files (no routing config generated for controllers).
Is there any plan to also generate the related files (like config)? Because otherwise MakerBundle sounds like what simple text editor snippet generators already do, only with the additional constraint of needing to be installed in your application (speaking of which, is there a plan to change the bundle into a standalone cli tool?).
The same for the other makers: Symfony 4 autowiring is so great, that you don't need to configure anything to make things work. That's why we have a generator for event subscribers but not for even listeners (which would require changing files).
For the moment we don't have plans to make this a CLI tool. It only works for modern Symfony apps which follow the dir structure proposed by Symfony.
Too bad it's not gonna be a CLI tool. Even if it's "Symfony only", having to install it in your application rather than globally feels a bit weird.
Anyways, keep up the good work!
I'm using symfony 4.0 RC and when I try to install the maker bundle I get a error message.
>composer require maker
[InvalidArgumentException]
Could not find package symfony/maker-bundle at any version for your minimum-stability (RC). Check the package spelling or your minimum-stabil
ity
Can you tell me if I need to do a special configuration before install the maker bundle?
I read the install doc here : https://github.com/symfony/maker-bundle/blob/master/src/Resources/doc/index.rst
Greetings!!!
I will be waiting for this useful feature :)
Congratulations to the Symfony developers Team!!!