Category : symfony-routing

Is it possible to create a URL with the Symfony Router with a custom query string parameter with no value? Ideally i’d like: https://crmpicco.co.uk/details?invalid_sms the code below gives me: https://crmpicco.co.uk/details?invalid_sms=1 $router->generate(‘crmpicco_personal_details’, [ ‘invalid_sms’ => 1 ]); I have tried passing null, but that is not an accepted value Source: Symfony4..

Read more

I have this regex setup ((^(?!edit/?$)^(?!recruiters/?$).*)) @Route("/{type}/{slug}", name="route-name", requirements={"slug"="(^(?!term/?$)^(?!anotherterm/?$).*)" }) My goal is that if slug is "term" or "anotherterm" it doesnt match this route. I have used different regex tools and it works fine, I have also tried testing using preg_match() and it works fine. Other tools I used are below and also https://www.debuggex.com/ ..

Read more

We want to open a DELETE endpoint that allows calls to all positive integers, but not id 1 (aka element 1 cannot be deleted) Usually to open an endpoint that allows positive integers I configure the route like this delete_elements: path: /elements/{id} methods: ["DELETE"] controller: app.elements_delete requirements: id: ‘d+’ For this case I tried to ..

Read more

Iam using react+symfony with webpack. Everything works with simple url eg. one slash in url ("/aboutus","/moodle") but when i try access route with multiple slashes("/admin/users") i get NotFoundResource Error. But with router:matchi will find it. Server log: Uncaught PHP Exception SymfonyComponentHttpKernelExceptionNotFoundHttpException: "No route found for "GET /admin/users"" at /home/rtkpf/Programming/Niners/vendor/symfony/http-kernel/EventListener/RouterListener.php line 136 router:match /admin/users (master) [1]> ..

Read more

I am trying to declare a subresource in my symfony app. I followed the api-platform doc about it: https://api-platform.com/docs/core/subresources/ The subresource does appear in the routes, but not under its parent resource. The routes I currently have: api_files_get_collection GET ANY ANY /api/files.{_format} api_files_post_collection POST ANY ANY /api/files.{_format} api_files_get_item GET ANY ANY /api/files/{id}.{_format} api_files_patch_item PATCH ANY ..

Read more

I have in my annotations.yaml following setup to use annotation route setup: controllers: resource: ‘../../src/Controller/’ type: annotation prefix: en: ” sr: ‘/es’ de: ‘/fr’ kernel: resource: ../../src/Kernel.php type: annotation My question here is can I create a separated area like mysite.com/userarea without locale prefix? It’s protected area and I can use users language. I tried ..

Read more

I’m trying to implement multiple controllers which listens to one route /account. There are two controllers and only one should be executed on that URL where the choice lies within user’s role. namespace AppBundleController; use AppBundleEntityRole; use SymfonyBundleFrameworkBundleControllerController; use SymfonyComponentRoutingAnnotationRoute; /** * @Route(“/account”) */ abstract class DashboardController extends Controller { protected $userRoles; public function __construct() ..

Read more