Symfony2: Getting Easier - Interactive Generators

Some people keep thinking that Symfony2 requires a lot of upfront configuration... even more than symfony1. It took me a while to understand why people would think so as there is nothing to configure in Symfony2 if you are using the Symfony Standard Edition, except the database settings if you need one (and this can be done from the browser).

But recently, I saw the light: people are talking about creating new bundles, new Doctrine entities, new CRUD controllers, ... symfony1 has generators for all those things, but until now, Symfony2 was not very good at generating code. Well, that's "fixed" now, thanks to the new GeneratorBundle. The bundle is included by default in Symfony SE (as of 2.0.0 RC1 which will be released on June 24th) and it knows how to generate bundles, forms, Doctrine entities, and simple CRUD controllers to get you started even faster.

The generators are even better than the ones in symfony1 as you can use them interactively; answer some questions and Symfony2 takes care of everything for you:

This screencast requires a more recent version of the Adobe Flash Player to display. Please update your version of the Adobe Flash Player.

The code is quite new and probably comes with a lot of bugs. Let's enhance it in the coming weeks!

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.

Symfony2: Getting Easier - Interactive Generators

Tweet this



All that was missing from SF2. SF2 feels so much more 'right', but I've kept with SF1.4 for most tasks because it was just that much quicker to work with.
Very nice!

It generates tests for entities and controllers?
@Stephan it generates a stub test file. You have to complete it by yourself but the code is commented and it's almost functional. We can't generate a complete test file as we can't know how to fill the form with data. For example, it's impossible to know if a "username" field must be filled with an email address or a string or something else.
I am in love. Congrats to the core team :)
That's great news! I really liked this functionality in 1.4 and am looking forward to using it again in Symfony2.

Is it possible to not use it interactively, but to pass all parameters in the command?

Also when working with Symfony CLI I recommend checking out my bash script to make that bit easier:
"The bundle is included by default in Symfony SE (as of 2.0.0 RC1 which will be released on June 24th) "

Great news! 2 days left :D
@Tobias Sjösten: Yes, you can use the commands without any interaction by passing the `--no-interaction` option. Also, you can pass some options on the command line and the values will be used as the default when interacting with the user.
Where is a video ? I see just black player
Nice. Good job.

Your Generator Bundle looks great, good job Fabien !! I will testing it...
This will be useful not only for the newcomers.
Generated code is a great way to standardize the code in Symfony1 and sure it will be true for Symfony2 too.

Thank you very much!
Great ! we can finally be productive with SF2 :)
Great news about RC1 coming in 2 days! I am really looking forward to test the new generator bundle.
Amazing! This rocks!!!
Greaaat !
And then there was light...
Thanks a lot
Looks Amazing!
I'm a Symfony2 newcomer, and i guess this makes my life easier.
Great !!
Great news! :) Great work!
Great!!!, I was waiting for this.
Wow, this is the killer feature of Symfony2, and something I've wanted for a long time. Really well done!
Looks great. Looking forward to using it!
Bravo! This really makes it easier to get started with the framework.
Video was so fast, I couldn't see all the features ! Need to pause a lot...

Great screencast and great job !
Great news!!!
Excellent! This is the right thing, it reduces the amount of routine work.

I have an idea, which could further increase the attractiveness of Symfony2. How about a a web interface to these generators? You already have awesome profiler.
Nice job there, really interesting stuff
One word: holyfriggincrap!
bien hecho amigos!
Excelent! this is a must have feature of every web application framework. Increases productivity a lot! Also servers as a good reference to standarize! Great Job!
That's great! This is really cool.

But I still miss an admin generator. Will be one?
Very exciting obout this! Also I'm worried about admin generator. Some people even are looking solutions out of symfony, because it is not a priority on Symfony2. Look here
Great proof of concept. I'm looking forward to admin generator(s) built similarly; I use the admin generator a lot with Sf 1.

I personally don't usually like the "wizard" approach, whether command line or web-based, because I always answer something wrong the first time. I like to reuse configuration from other projects/machines, use version control, and search and replace. For all those reasons, I prefer file-based configuration (I love schema.yml and generator.yml). But it looks like that's all still possible so cool.
Looks fantastic, can't wait to try it out when I get home.
ahora las cosas básica que hacen mas rápidas, muy buena iniciativa.

I can't call that "awesome", "wonderful" nor "amazing" ... It's far beyond that.
Gracias, era lo único por lo que retrasé durante tanto tiempo mis proyectos. Definitivamente era lo único que hechaba de menos de sf1.

Bien hecho muchachos!
OMG this is GREAT!!!! finally! i was soo tierd of doing this by hand, lol. I hate repetitive tasks.
Awesome job. The interactivity is great. Any talk of generating unit tests on the getters and setters for entities?
I noticed this in the sensio github repository and was excited for what was to come. Good to see what this tool can provide, and looking forward to using it if it suits what I need to do!
Woww!! really great job!! it's a very nice feature
Fuuuuu**********k! Awesome! I had an orgasm (yes I did). This is a killing feature, but for sure the lack of it doesn't mean S2 is useless (as someone pointed) Hey! I'm already making $$ with it, and without the generator (yet). I do really love it a lot more than S1. Less magic translates it into less tweaking the generated code, and this doesn't look like magic but a terrible helpfull utility.
Nice job!
1 question, though: how does the gen:doctrine:entity relate to doctrine:generate:entitites?
Will this command be replaced or is this new command an extra tool to generate yaml files (for instance) that can be used for Entity generation with doctrine:generate:entities?
Waited by so many :)

Can you make all the options configurable instead of interactive?

There is any command to "generate all"?

A nice feature will be generator profile, that including generator options and templates (except probably those parts generated by doctrine), specially view templates.
Both Chrome and Firefox give me a black background, but the player seems to think that it is displaying something as it is progressing the ticker. IE displays the video though.

Anyone else experiencing this?
That is an absolutely fantastic and useful addition. Thank you very much.

You probably already know this, but you've wet everyone's appetite with anticipation for RC2, in the hopes that perhaps there might be some more surprises.

(sortable columns, pagination, filtering, ...)

But even if not, still, thanks very much for all you do for the community.
Hello, any idea how to integrate it into an existing symfony 2 project ? also can it generate complete forms based on entities ?
@Fabien Interactive generation is great BUT can I pre-define generation spec/config for bundles/entities etc. if I dont want to go through generating items one by one? This could mean that down the track a user could generate entire applications out of a generator-spec. Somewhat similar to how Schema.yml is used in SF1.
That's an awesome addition. Symfony's definitely kicking some serious ass!
Really like the DialogHelper, I was looking for something like it in these days. I'm going to wait for RC1 release.
Sorry, stupid me: DialogHelper It's already there in the Console related components.
yeah. good job. That's the right thing for a new beginner, a lazy man.
i think , a rapid development tool, need automation features.
make most practical work more easier just a command line.
so we can list those most practical work, then make generator to automake .
7) .....
very powerful and easy to use , thank you !
RC1 upgraded , bundle generate OK!
You guys should at least test the code on windows before releasing it.

Tried to follow the video to generate a bundle but twig threw a fatal error during the process.
Hi, your demo code generates the Entity with Doctrine generation, @ORM relation and works correctly but in the release there is no @ORM relation and Entity files are being generated differently compared to the screencast which throws exceptions when reading the annotations.

I believe your local is different than RC1 and those changes did not make it into the RC1, check it out when you have time.
You guys should at least test the code on windows before releasing it. Tried to follow the video to generate a bundle but twig threw a fatal error during the process. [2]
generate:bundle does not work for me under Windows :/

I get this error:
Unable to find template "C:/wamp/www/Symfony/src/MyAp/FilmothequeBundle/Controller/DefaultController.php" (looked into: /).
Namaste and Hello,

Thanks for such an elegant MVC framework...i really got attached with the developmental works and portfolio included in Website about "Symfony".

[email protected]
Amazing work! Tested it on RC3 and works like a charm.

This saves a LOT of coding and created everything exactly as I would have done it the hard way. I even created the database first when I realized that there's no need to do that, because this will generate everything!

Note: The validation messages that should appear after we submit the form don't show up on Chrome (latest version) and Firefox (latest version), they only show correctly on Internet Explorer.
Hi. Great job but the I am not able to get to URL/post/.
All files gets created right but I think a configuration on routing.yml or config.yml may be missing on Symfony2 RC4. Does someone gets the same error?
I get a:
No route found for "GET /post/"
So i believe the error is due to a windows incompatibility. Console error is:

Importing the bundle routing resource: FAILED

The command was not able to configure your everything automatically.
You must do the following changes manually.

Bundle UdmFutBundle is already imported.
I did all as in this video, from clear installing symfony2.
In the end I got "No route found for "GET /post/"
Using windows and Symfony2 Standard RC2
I'm checked router list by using "router:debug" command but nothings about "Post" action in routing list.

Check my screenshot.
I did all as in this video, from clear installing symfony2.
In the end I got "No route found for "GET /post/"
I using windows and Symfony2 Standard RC2
I'm checked router list by using "router:debug" command but nothing about "Post" action in routing list.

Check my screenshot
Oh My Mistake, I using Symfony 2 Standart RC4 :) but not RC2
Anybody know what the problem with router in RC4 after generated crud?
I've just installed symfony 2 RC4 with vendors. And when i click on "go to welcome page" i've got the error : NotFoundHttpException: No route found for "GET hp/" . It's a fresh install and already broken...

Does anybody have find a solution for that matter : "The command was not able to configure your everything automatically.
You must do the following changes manually. " ?

I use the RC4.

Thanks a lot.


Comments are closed.

To ensure that comments stay relevant, they are closed for old posts.