logo
down
shadow

Symfony2 - Managing routes involving 2 kinds of bundle


Symfony2 - Managing routes involving 2 kinds of bundle

By : Thore Cardel
Date : November 19 2020, 03:59 PM
This might help you I Came to find out that I should have created FirstBundle/Resources/config/routing.yml file as followed:
project_first_aroute:
code :
path:    /a-route

host: "{subdomain}.{domain}"

defaults: { _controller: ProjectFirstBundle:Public:aroute, domain: "%project_domain%" }      

requirements:

  domain: "%project_domain%"

  subdomain:  'first'


Share : facebook icon twitter icon
Is there a way to export routes from Symfony2 bundle via DependencyInjection

Is there a way to export routes from Symfony2 bundle via DependencyInjection


By : Running Pixel
Date : March 29 2020, 07:55 AM
This might help you At the moment you can't easily hook into the routing like that from a Bundle, that's why the framework stuff itself like the profiler and web debug toolbar have to be included from the routing_dev.yml file.
However it would be doable I believe to add an event dispatched when the routing is parsed I guess, allowing bundles to hook into it to add their own routes to the RouteCollection. I created an issue to that effect on the Symfony tracker.
Symfony2 bundle inheritance losing parent bundles routes

Symfony2 bundle inheritance losing parent bundles routes


By : WelsonDev
Date : March 29 2020, 07:55 AM
wish helps you I found the right solution for this issue. Today I was also trying to override a parent bundle configured with annotations routing and also found that parent routes were ignored if the anotation routing imported the whole bundle ("@SomeBundle/Controller").
After a little debugging I found that the explanation for this is that if you use "@" as prefix for the controller this will pass to the kernel resolver which will return ONLY the child resource if the parent resource has been overridden. So the solution is to provide the full path of the bundle, considering that the kernel will try to match the resource from app/Resources so you will have to add a relative directory (../../) before the actual path:
code :
# app/config/routing.yml:
some_parent:
    resource: "../../src/Application/ParentBundle/Controller"
    type: annotation

# ChildBundle implements getParent() method to inherit from ParentBundle
some_child:
    resource: "@ChildBundle/Controller"
    type: annotation
Symfony2: Can bundle routes be namespaced?

Symfony2: Can bundle routes be namespaced?


By : lavanya g
Date : March 29 2020, 07:55 AM
I wish this helpful for you It's not built into the routing system. You would have to manually prefix your route names with the bundle or some other namespace.
The FOSRestBundle has route prefixing functionality but I'm not sure how coupled it is or if it's something that could be easily used without all the bundles other features.
Symfony2 - 2 routes to same bundle (optional parameter)

Symfony2 - 2 routes to same bundle (optional parameter)


By : walkingm
Date : March 29 2020, 07:55 AM
will be helpful for those in need I need my website to be accessible with 2 different URL, for example: , You should try this in your routing.yml:
code :
mywebsite_blog:
    resource: "@MywebsiteBlogBundle/Resources/config/routing.yml"
    prefix:   /{_label}blog/
    defaults: {_label: mylabel/}
    requirements:
        _label: ([\w\d]+/)?
app/console router:match /mylabel/blog/  # OK
app/console router:match /blog/          # OK
Symfony2: add routes from my bundle

Symfony2: add routes from my bundle


By : Elisabeth Hundt
Date : March 29 2020, 07:55 AM
around this issue 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.
shadow
Privacy Policy - Terms - Contact Us © ourworld-yourmove.org