symfony-routing

Get the route name in a Symfony service [duplicate]

和自甴很熟 提交于 2020-12-13 03:45:07
问题 This question already has answers here : Getting the route name inside a service in symfony (2 answers) Closed 2 years ago . Im try to get the name of the current route in a Symfony 4 service. routes.yaml test-route: path: /test controller: App\Controller\Test::test service class Myservice { private $u; public function __construct(Utilities $u){ $this->u = $u; $route = getRouteSomehow(); // should return "test-route" } } I found this piece of code to grab the route: $requestStack-

How to debug (and fix) Symfony2|3 routes?

半城伤御伤魂 提交于 2020-01-06 20:04:06
问题 I have this routes defined at app/config/routing.yml in a Symfony 2.8 app: platform_chat: resource: "@PlatformChatBundle/Controller/" type: annotation prefix: /chat platform_admin: resource: "@PlatformAdminBundle/Controller/" type: annotation prefix: /admin #----> this is part of routing.yml but I forgot to add it easy_admin_bundle: resource: "@PlatformAdminBundle/Controller/AdminController.php" type: annotation prefix: /admin #FOSUser fos_user: resource: "@FOSUserBundle/Resources/config

Symfony2 Routing: Method Not Allowed (Allow: {Method})

╄→гoц情女王★ 提交于 2020-01-02 03:12:09
问题 so in routing.yml I have the following routes defined in order to edit and delete specific settings: routing.yml: settings.editDefaults: path: settings/{id}/defaults/edit/{widgetType} defaults: { _controller: AppBundle:Settings:editDefaults } methods: [POST, PUT] settings.deleteDefaults: path: settings/{id}/defaults/delete/{widgetType} defaults: { _controller: AppBundle:Settings:deleteDefaults } methods: [DELETE] And in my controller I have the correct actions defined: SettingController.php:

Symfony 3.0 - Cannot load resource “.” - Custom Route Loader

主宰稳场 提交于 2019-12-24 02:25:40
问题 I am working on upgrading one of my projects to SF 3: The project uses some custom routing loaders which where working without problems before, now I am getting a FileLoaderLoadException stating that the resource "." couldn't be loaded. I took a look at the documentation: http://symfony.com/doc/current/cookbook/routing/custom_route_loader.html But either nothing has changed or the documentation has not been updated. My routing.yml configuration looks like this: custom_sidebar_routing:

How to use anchors in Symfony routing?

做~自己de王妃 提交于 2019-12-23 12:08:11
问题 I have defined a route as followed in my routing.yml file : route_name: path: "/dashboard#messages/{id}" However when I ask Symfony to generate that route, I get : /dashboard%23messages/12345 How can I skip the encoding part of the route generation? Or how can I escape the # char in the path definition? PS : Working with a (big) legacy system, I cannot change the urls. 回答1: Available from Symfony 3.2. Support for anchors has been announced for the routing component using the fragment variable

Symfony2: No route found for “GET /lucky/number”

我是研究僧i 提交于 2019-12-21 06:50:39
问题 I start the tutorial (as newbie) and everythings works fine till: http://symfony.com/doc/current/book/page_creation.html#creating-a-page-route-and-controller at step Creating a Page: Route and Controller I have created a file called /var/www/html/[projekt]/src/AppBundle/Controller/LuckyController.php but when I open http://[Server-IP]:8000/app_dev.php/lucky/number is always get a 404: No route found for "GET /lucky/number" 404 Not Found - NotFoundHttpException 1 linked Exception:

How does the login check_path route work without default controller/action?

半世苍凉 提交于 2019-12-17 05:01:43
问题 I am working on symfony 2.3 project having the following routing code just2_frontend_logincheck: pattern: /login_check It doesn't have defaults:{ _controller: testBundle:User:login } But it is working. But I don't know how the routing is working. Is it possible? Please advice me about the routing. 回答1: The check_path route/path is used by your firewall to catch login requests. This route's action is never really accessed. It's the route/url your login form posts to and the request should be

Access global parameters from route condition expressions in Symfony

心不动则不痛 提交于 2019-12-12 08:57:19
问题 I'm trying to access app-wide symfony parameters (defined in app/config/parameters.yml) from an expression in a route condition (documentation). I tried my luck inserting the parameter within percentage signs and through the function "parameter" (as described for DI here), both to no avail. Here is the example with the parameter function: example_route: path: /example/{_locale} condition: "request.getLocale() in parameter('locales_array')" defaults: _controller: "AcmeExampleBundle:Example

Route is in debug list but returns 404 in Symfony 4

删除回忆录丶 提交于 2019-12-10 12:45:45
问题 Ok, so I just installed latest version Symfony 4. Run the browser after installation and a nice welcome greeting shows. All good! Then I created a new controller using make:controller . I named this controller Client and is using Annotations, same with the other Default Controller. I configured the routing as follows: /** * @Route("/client", name="client") */ public function index() { // replace this line with your own code! return $this->render('@Maker/demoPage.html.twig', [ 'path' => str

Symfony2 Routing: Method Not Allowed (Allow: {Method})

旧时模样 提交于 2019-12-05 06:53:35
so in routing.yml I have the following routes defined in order to edit and delete specific settings: routing.yml: settings.editDefaults: path: settings/{id}/defaults/edit/{widgetType} defaults: { _controller: AppBundle:Settings:editDefaults } methods: [POST, PUT] settings.deleteDefaults: path: settings/{id}/defaults/delete/{widgetType} defaults: { _controller: AppBundle:Settings:deleteDefaults } methods: [DELETE] And in my controller I have the correct actions defined: SettingController.php: /** * edit the default settings of a hotel/widget */ public function editDefaultsAction(Request