It is a pity the bundle namespace and bundle name were given the same name. If they weren't is would be easier to distinguish them later. Also I don't get an option for a Bundle namespace so I can't put in a vendor i.e. Yoda. I am only asked for 'Bundle name:'. It is strange that the bundles which are essentially apps are in the src and not app directories. Doesn't seem intuitive.
Yea, I agree - this definitely leads to "what is the bundle name?" versus "what is the namespace"? Starting in later versions of Symfony, we've simplified this: we now recommend that your app just has *one* bundle: AppBundle. We cover that in the latest version of this tutorial: http://knpuniversity.com/sc.... But, you can of course do whatever you want :).
And that's also why you see differences in this command: once we started recommending AppBundle we (actually I did this) updated the command to be more user-friendly and also to push people a bit more towards the idea of just having one bundle. There is an earlier question asking you if this bundle will be "shared". If you answer "yes" to this, then it will ask you for a vendor namespace. But if you answer no, there's no reason really to have a vendor namespace - it just makes your namespaces / directories a bit deeper. So, that's what's going on there!
And finally - very interesting through bout the app/ directory! This is actually something we considered when we moved to the AppBundle idea! One of the biggest reasons we didn't do this is simply to keep things consistent with how they were in the past. Putting your bundle in app versus src are both valid, but everyone has become accustomed to src, and putting things in app/ doesn't have any extra advantage. But with the AppBundle approach, there is a key delineation between app and src: src/ should contain your PHP code and app/ should contain everything else (templates, configuration, etc).
But, there's a cool addendum to this discussion :). *If* you wanted to put your AppBundle into the app/ directory (so you have app/AppBundle... or even, to that you remove AppBundle and have things simply like app/Controller, app/Entity, etc) you can do this very easy: simply change the autoload in your composer.json to point to app/ instead of src/ https://github.com/symfony/....
Phew! I hope that at least somewhat clarifies! This tutorial is now out-of-date, but also, you're asking (or commenting about) some very insightful questions.
Cheers!
Please, log in to vote for this comment
|
Share Comment
"Houston: no signs of life" Start the conversation!
2 Comments
It is a pity the bundle namespace and bundle name were given the same name. If they weren't is would be easier to distinguish them later.
Also I don't get an option for a Bundle namespace so I can't put in a vendor i.e. Yoda. I am only asked for 'Bundle name:'.
It is strange that the bundles which are essentially apps are in the src and not app directories. Doesn't seem intuitive.
Hey Shane!
Yea, I agree - this definitely leads to "what is the bundle name?" versus "what is the namespace"? Starting in later versions of Symfony, we've simplified this: we now recommend that your app just has *one* bundle: AppBundle. We cover that in the latest version of this tutorial: http://knpuniversity.com/sc.... But, you can of course do whatever you want :).
And that's also why you see differences in this command: once we started recommending AppBundle we (actually I did this) updated the command to be more user-friendly and also to push people a bit more towards the idea of just having one bundle. There is an earlier question asking you if this bundle will be "shared". If you answer "yes" to this, then it will ask you for a vendor namespace. But if you answer no, there's no reason really to have a vendor namespace - it just makes your namespaces / directories a bit deeper. So, that's what's going on there!
And finally - very interesting through bout the app/ directory! This is actually something we considered when we moved to the AppBundle idea! One of the biggest reasons we didn't do this is simply to keep things consistent with how they were in the past. Putting your bundle in app versus src are both valid, but everyone has become accustomed to src, and putting things in app/ doesn't have any extra advantage. But with the AppBundle approach, there is a key delineation between app and src: src/ should contain your PHP code and app/ should contain everything else (templates, configuration, etc).
But, there's a cool addendum to this discussion :). *If* you wanted to put your AppBundle into the app/ directory (so you have app/AppBundle... or even, to that you remove AppBundle and have things simply like app/Controller, app/Entity, etc) you can do this very easy: simply change the autoload in your composer.json to point to app/ instead of src/ https://github.com/symfony/....
Phew! I hope that at least somewhat clarifies! This tutorial is now out-of-date, but also, you're asking (or commenting about) some very insightful questions.
Cheers!
"Houston: no signs of life"
Start the conversation!