Category: symfony-routing

Subresources routes in symfony 5 with API-platform

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…

Symfony routing, separate route setup and ignore _locale prefix?

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…

How to use different controllers, depending on the user role, for the same route?

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;…

Symfony onKernelRequest headers->set dont received on @Route

I have functionm onKernelRequest when i want to add some custom header(in my case api=true||$request->headers->set(‘api’, “true”)) and in all Request $request i can get that header but when i try it on annotation its fail: onKernelRequest: public function onKernelRequest(RequestEvent $event)…

Validate optional input GET parameters passed in through the querystring as integers in Symfony 3.4

In Symfony 3.4, is there a way to validate optional input GET parameters passed in through the querystring as integers? If provided, I am using the $ownerId and $courseId to query the corresponding repositories, however the value needs to be…

How to add prefix to some controllers using annotations?

I have at the moment two controllers. GitlabAuthController UserController I need to add the path prefix api to UserController only. Before I was trying following at annotations.yaml file: controllers: resource: ../../src/Controller/ type: annotation prefix: api But this adds the prefix…