
Routing & Controllers
Route annotations, parameters, constraints, redirects, Request/Response, JSON responses
1Which PHP attribute should be used to define a route in a Symfony 7 controller?
Which PHP attribute should be used to define a route in a Symfony 7 controller?
Respuesta
The #[Route] attribute from the Symfony\Component\Routing\Attribute namespace is the recommended method for defining routes in Symfony 7. It replaces Doctrine annotations that required special comments. Native PHP attributes provide better IDE integration and compile-time validation.
2How to define a dynamic route parameter in Symfony?
How to define a dynamic route parameter in Symfony?
Respuesta
Route parameters are defined using curly braces in the route path, for example {id}. This parameter is then automatically injected as an argument to the controller method with the same name. This convention allows automatic binding between the URL and controller parameters.
3Which Symfony object represents the incoming HTTP request?
Which Symfony object represents the incoming HTTP request?
Respuesta
The Request class from the Symfony\Component\HttpFoundation namespace encapsulates all HTTP request data: GET/POST parameters, cookies, headers, uploaded files. It can be automatically injected into controller methods thanks to Symfony's autowiring.
How to restrict a route to a specific HTTP method?
How to return a JSON response from a Symfony controller?
+17 preguntas de entrevista
Otros temas de entrevista Symfony
Modern PHP (8.1+)
Symfony Basics
Twig & Templates
Doctrine ORM Basics
Symfony Forms
Data Validation
Dependency Injection & Services
Security & Authentication
Doctrine Advanced
API Platform
Serializer Component
Events & Event Subscribers
Console & Commands
Messenger Component
HTTP Client
Cache & Performance
Workflow Component
Testing Symfony
Mailer Component
Translations & i18n
EasyAdmin Bundle
Symfony Architecture
Performance & Optimization
Security Advanced
Custom Bundles
Microservices with Symfony
Real-time & WebSockets
Deployment & DevOps
Domina Symfony para tu próxima entrevista
Accede a todas las preguntas, flashcards, tests técnicos, ejercicios de code review y simuladores de entrevista.
Empieza gratis