Create bundle without default controller and route - symfony

Is this possible to create bundle without default controller and route?

Yes, it is. Only required file in the bundle is the bundle class.
Read more in the official documentation: http://symfony.com/doc/current/book/page_creation.html#the-bundle-system

Related

Symfony 2.7: How to change route in code?

I have a website based on symfony. Routes are declared with yml-files. I use a 3rd-party extention, but wanted to change it's urls. I want to avoid changing the yml-files of this extention because they will be overwritten with the next update. Is there a way to change the route in my php-code instead of the yml-file?
copy the routing file into your application and import it
from symfony doc
Routing is never automatically imported in Symfony.
If you want to include the routes from any bundle, then they must be manually imported from somewhere in your application
(e.g. config/routes.yaml).
The easiest way to "override" a bundle's routing is to never import it at all.
Instead of importing a third-party bundle's routing, simply copy that routing file
into your application, modify it, and import it instead.

Symfony: How to handle config in Bundle

I'm having trouble finding the correct tutorial for me. I'm trying to have a controller-configuration in my bundle in Resources/config/someconfig.yml. I already adjusted it to a .yml extension. Now I'm searching a solution to access this configuration inside a twig exception controller (404-pages) and merge this configuration with the config.yml in app/config/.
Can anybody help me with a tutorial link or tips?
Thank you!
To get Resources/config/someconfig.yml config you can create DI extension: http://symfony.com/doc/current/cookbook/bundles/extension.html
I think this can help you to get configuration value in view: How to get config parameters in Symfony2 Twig Templates
As an alternative you can override Exception controller (get configuration parameters there and pass them to the view): http://symfony.com/doc/current/cookbook/controller/error_pages.html#replace-the-default-exception-controller
For merging configurations among independent bundles you should use prependExtensionConfig method and PrependExtensionInterface interface.
Documentaion page How to Simplify Configuration of multiple Bundles explains this technique in great detail.

Inject additional configuration into custom Entity/Document Manager

I made a custom Document Manager for my project implementing some new low level functions (following this post).
Now I would like to inject a custom configuration in my new Document Manager (I suppose it would be the same with an Entity Manager). I have no idea of how to do this...
I want this config in my yaml files to set my custom Document Manager's parameters. The only way I found until now is to write a static function returning a hardcoded array of configuration, but it's a little dirty...)
Is there a proper way or an alternative to do this?
For defining custom configuration in the conig.yml file, use this symfony docs. You can access those configurations easily in a controller:
$this->container->getParameter(name_of_bundle_here)

Symfony2: add routes from my bundle

I created a bundle wjb/ImageBundle but I would like to load its routes without modifying app/config/routing.yml. From FOSRestBundle and few more, I see it is possible but I coudn't figure a way how to do that.
Is there some idiot-proof tutorial? I would like to use annotations but I would accept any other way too.
It's not possible to have routes in your application without registering them.
FOSUserBundle's routes can partly be defined in your security.firewalls configuration.
The others have to be imported as well described in the documentation chapter #6 - FOSUserbundle import routing files.
A workaround may be adding routes when loading a bundle without touching your routing.yml in a CompilerPass.

Symfony2 - how to assign Doctrine Entity as Route resource?

I want to dynamically change my routes based on settings was stored in database, how I can do this in Symfony2?
You can use this bundle to replace Symfony default routing system to a dynamic one.

Resources