Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Generates Symfony2 bundles, entities, forms, CRUD, and more...
PHP

feature #312 Update generate:bundle for non-shared bundles and more (…

…rafix, weaverryan)

This PR was merged into the 3.0.x-dev branch.

Discussion
----------

Update generate:bundle for non-shared bundles and more

Hi guys!

If you're reading this, please try this out and offer any feedback! There are so many different cases, it will make @fabpot's life much much easier (and that's always good).

This replaces (adds to) @rafix's work on #299. The task ended up being a bit larger, because there are so many things we *could* change, and we need to communicate things well.

Fortunately, the changes here alter the generation process very little - most changes are to *how* we ask the questions. Here are the highlights:

* if a bundle is non-shared, we only ask for a bundle name, not a namespace
* removed "generate full directory structure" functionality entirely. This added only a few extra files, which I don't think add value.
* make `.yml` the service configuration format if you choose annotation format. If you're using annotation for routing, it's likely you're following the best practices are you might be surprised by XML :)
* many small output changes

BC breaks:

* `BundleGenerator::generate` is now gone
* The `structure` option was removed
* You now get `services.yml` if you choose annotation as your format

In #299, we asked the question "should a non-shared bundle have a `Resources/` directory?". I think it should. Why? I think the `AppBundle` is special - it's the one bundle that's truly coupled to your kernel (e.g. `app/` directory), which is why it's ok to store the templates in `app/`. If we also stored templates from other bundles in `app/`, it gets a crowded. If you had a `DefaultController` in 2 bundles, their templates would "want" to occupy the same space (e.g. `app/Resources/views/default/*`).  So, I think it makes sense to have only one special bundle (per kernel) that you really *couple* to the kernel. *IF* you choose to add other bundles (which you don't need to do), I think you should organize them more along the lines of traditional bundle, at least for templates.

### TODOS

* [x] Import services.xml/yml manually from config.yml for non-shared bundle
* [x] Can we break BC in the ways described above? Or do I need to re-add somethings?
* [x] Fix the GenerateBundleCommandTest
* [x] Add more cases to BundleGeneratorTest for no DI directory
* [x] Fix BundleGeneratorTest

What does everyone think? /cc @javiereguiluz

Thanks!

Commits
-------

e632cb8 Removing docs for now-gone option
712235e updating the test because we now ALWAYS ask questions, unless you pass --no-interactive
483ab4b Coding standards
1dd31e3 Removing an extra / in the target directory (was ok, but looked bad in messaging)
8ee423b Fixing a bug where we required the vendor namespace in the exact wrong situation
a802785 Displaying path to AppKernel in messaging
2673bb4 Fixing wrong separator for namespace
079250f Not asking for the bundle if you're in non-shared mode - it was asking twice
ae3db97 Fixing default value to be dependent on the "shared" value
baab95e Cleaning some things up and changing the behavior to ask questions even if they're passed to the command line (it simplifies the code a lot)
c5785e4 Trying to fix my rebase
89d3ee6 Fixing coding standards
5ae77db Fixing another test now that the Bundle object is being passed
c66ed09 Fixing bad indentation (caught by tests!)
de0c682 Fixing test by using new Bundle object
8a768ac Fixing bad base class for test
cb4b1b9 Tweaking language based on comment from @samsonasik
7a41f5c Adding the ability to import a configuration file from app/config/config.yml
7a6033b Adding a Bundle model object to help centralize its metadata
48ced20 Removing an old, unused method
955fae6 Fixing code standards
5fa687a Fixing a number of tests!
e7645da Improving error message on the validator - just a bit more helpful when I'm doing tests
5537e9c Revert "fixing a bug where we'd ask shared even if it were passed as false"
e935050 fixing a bug where we'd ask shared even if it were passed as false
e388b40 Fixing bug that caused paths to be missing a slash
a55f65f Adding line breaks, but no changes
bfd1916 Fixing coding standards
f0d0b95 Tweaks thanks to @javiereguiluz
ad28da8 Major overhaul of the interaction part of the generate:bundle command
42c32d4 Very minor code tweaks (no functional stuff)
4af1618 CS fix
3d65d3c better explanation for --shared option
bc058c7  = false in generate method :)
1b5f7fb [WIP] optional vendor's name
8e4e023 shared option set to false by default
5f3233b droped shared element from parameters array in Generator/BundleGenerator.php
5f4d06c docs fixed
763e2f1 more on test
1d4600c [WIP] more on test
f541d16 fix test errors in Tests/Command/GenerateBundleCommandTest.php
ac39c7a patch applied
778caf2 [DX] Re-work generate:bundle for simple app bundles #290
latest commit 8c24b21dd1
@fabpot fabpot authored

README.md

SensioGeneratorBundle

The SensioGeneratorBundle extends the default Symfony2 command line interface by providing new interactive and intuitive commands for generating code skeletons like bundles, form classes, or CRUD controllers based on a Doctrine 2 schema.

More information in the official documentation.

Something went wrong with that request. Please try again.