Typically, bundles perform tasks that are all related. For example, your 
blog would be a bundle. You'd include everything needed to manage your blog 
in that bundle. Default views, services, configuration, routing, etc. 
Depending on how big the rest of your site is and on the functionality you 
need, the rest of your site may or may not be another bundle. If you have 
image galleries, you may want to create a GalleryBundle to manage those. The 
idea is to decouple that functionality from your other bundles and then use 
it in your application. You can rely on other bundles if necessary, but 
typically the way to do this is to inject dependencies by using the 
dependency injection design pattern:

http://symfony.com/doc/2.0/book/service_container.html
http://symfony.com/doc/2.0/cookbook/controller/service.html
http://fabien.potencier.org/article/11/what-is-dependency-injection
http://en.wikipedia.org/wiki/Dependency_injection (Fabien's blog entry is 
much better than this article but it may still prove helpful)

Unfortunately, there isn't a whole lot of documentation on how to do this 
just yet. But there are some bundles in development that show off some good 
examples:

https://github.com/FriendsOfSymfony/UserBundle
https://github.com/knplabs/symfony2bundles

Take a look at how they define their controllers and also look at the 
DependencyInjection directories. Definitely start with the first two links I 
provided though. It may take a bit of work to fully grasp what it is that's 
going on with this part of Symfony2. It's incredibly powerful and flexible 
once you wrap your head around it. :)

When it comes your second question, the idea is that you have base 
configuration files and views that exist regardless of the settings in your 
bundles. These settings are unique to a particular application. For example, 
you could have a BlogBundle that relies on the base.html.twig template in 
app/Resources/views/. It doesn't know how base.html.twig handles layout. It 
just knows that it exists and can display its information somehow. It's up 
to the writer of each application to determine how to use the functionality 
of the bundle.

You can also override templates in bundles by putting your own versions of 
them of them in app/Resources/<BundleName>/views/. You can even do this with 
the core bundles (e.g., if you want exceptions to be rendered to match the 
rest of your site).

http://symfony.com/doc/2.0/book/templating.html#overriding-bundle-templates

I don't know if I explained this very well (late night last night) but 
hopefully this will help some. :)

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to