Menu
  • HOME
  • TAGS

Doubts around Symfony2 Routing component usage

php,symfony2,fosrestbundle,symfony-routing

(1) can be done using the method described in the book article you referenced as not being helpful: As you've seen, a route can be made to match only certain routing wildcards (via regular expressions), HTTP methods, or host names. But the routing system can be extended to have an...

Restrict routes to a Ajax call, it's possible in Symfony 2.6+?

php,jquery,ajax,symfony2,symfony-routing

You could do so in a kernel.request listener. class DisallowNonXmlHttpRequestListener { public function checkRequest(GetResponseEvent $event) { if (!$event->getRequest()->isXmlHttpRequest()) { throw new AccessDeniedHttpException(); } } } And in your services config: services: disallow_non_xml_http_request_listener: class: DisallowNonXmlHttpRequestListener tags: [{ name: kernel.event_listener, event: kernel.request, method: checkRequest }] ...

Symfony2 can't find Route on custom Route Loader

php,symfony2,routing,routes,symfony-routing

You must also configure service # src/Gabriel/AdminPanelBundle/Resources/config/services.yml your_bundle.routing_loader: class: Gabriel\AdminPanelBundle\Routing\AdvancedLoader tags: - { name: routing.loader } And routing file # app/config/routing.yml YourBundle_extra: resource: . type: advanced_extra ...

Route names starting with underscore in Symfony2

symfony2,symfony-routing

It's only a naming convention. But the Framework will handle the routes by matching the first route defined with the matching url requested, then the second one and so on... So in your case, even if you requested http://www.mysyte.com/admin/whatever, it will match this url with all the routes in routing_front.yml...

Get value from URL in Javascript|jQuery and Symfony2 project

javascript,php,jquery,symfony2,symfony-routing

Try using this function: function getParameters(){ var url = window.location.href; //get the current url var urlSegment = url.substr(url.indexOf('proceso/')); //copy the last part var params = urlSegment.split('/'); //get an array return {registro: params[1], solicitud: params[2]}; //return an object with registro and solicitud } Then you can call the function and use...

Symfony2 wildcard routing

php,symfony2,twig,symfony-routing

There is a cookbook covering this specific use case: http://symfony.com/doc/current/cookbook/routing/slash_in_parameter.html By default, the Symfony Routing component requires that the parameters match the following regex path: "[^/]+". This means that all characters are allowed except "/". You must explicitly allow "/" to be part of your parameter by specifying a more...

Circular reference detected in routing_dev.yml

php,symfony2,fosrestbundle,symfony-routing,nelmio-api-doc

Thanks to users on Symfony2 group I have found a workaround and I will share here. After do a long research I found this SO topic among others and yes, theres is not mention around annotations and mix config files or whatever that was causing the circular reference, in a...

Where should I put Symfony third-party bundle's routing configuration?

php,symfony2,routing,symfony-routing

It's because we usually import our own routers in app/config/routing.yml file. But there are some drawbacks here, if you disable your own custom bundle they also stop working. That's why put them into app/config/routing.yml if you want not to break your application's functionality even if you disable your own bundles.