# symfony/routing

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/symfony-routing).**

7,618 stars · 93 forks · PHP · MIT

## Links

- GitHub: https://github.com/symfony/routing
- Homepage: https://symfony.com/routing
- awesome-repositories: https://awesome-repositories.com/repository/symfony-routing.md

## Topics

`component` `php` `router` `routing` `symfony` `symfony-component` `uri` `url`

## Description

This PHP routing library is an HTTP request router and matcher designed to map incoming URL paths to specific controller actions using defined patterns and configuration. It serves as a programmatic interface for defining, loading, and resolving URL patterns, while providing a URL generator to produce absolute or relative URIs from route names and parameters.

The system supports diverse route loading through YAML, XML, PHP arrays, and class attributes, utilizing compiled route matching to optimize performance. It enables sophisticated request handling through regex-based path matching, sub-domain routing, and localized route paths. To handle high-volume dynamic URL sets, the library provides a mechanism for route resolution via a database index.

Broad capability areas include HTTP route validation via regular expressions, the restriction of routes by HTTP method, and the use of expression-based conditional matching to evaluate requests based on runtime context. It also supports route grouping with shared prefixes and the ability to sign and verify URIs for integrity.

## Tags

### User Interface & Experience

- [URI-to-Controller Mappings](https://awesome-repositories.com/f/user-interface-experience/view-to-data-mappings/controller-to-component-mappings/uri-to-controller-mappings.md) — Associates incoming URL paths with specific controller classes and methods to handle the request. ([source](https://symfony.com/doc/current/controller.html))
- [Database Entity Resolvers](https://awesome-repositories.com/f/user-interface-experience/asynchronous-data-fetching/route-resolvers/database-entity-resolvers.md) — Queries a database for a specific object based on a URL parameter and passes the result to the controller. ([source](https://symfony.com/doc/current/best_practices.html))

### Web Development

- [HTTP Routing](https://awesome-repositories.com/f/web-development/routing-systems/http-routing.md) — Maps incoming URL paths to specific controller actions using defined patterns and configuration.
- [Attribute-Based Routing](https://awesome-repositories.com/f/web-development/attribute-based-routing.md) — Maps HTTP requests to controllers using metadata attributes on target methods. ([source](https://symfony.com/doc/current/best_practices.html))
- [Controller-Action Routing](https://awesome-repositories.com/f/web-development/controller-action-routing.md) — Maps incoming HTTP request paths directly to specific controller actions. ([source](https://symfony.com/doc/current/routing.html))
- [HTTP Methods](https://awesome-repositories.com/f/web-development/http-methods.md) — Enables limiting which HTTP verbs a specific route responds to and rejecting unsupported methods. ([source](https://symfony.com/doc/current/routing.html))
- [HTTP Routers](https://awesome-repositories.com/f/web-development/http-routers.md) — Provides a complete system for mapping incoming HTTP request paths to handler functions using patterns and methods.
- [Multi-Format Route Loading](https://awesome-repositories.com/f/web-development/multi-format-route-loading.md) — Supports loading route configurations from YAML, XML, PHP arrays, and class attributes.
- [PHP Routing Libraries](https://awesome-repositories.com/f/web-development/php-routing-libraries.md) — Serves as a programmatic interface for defining and resolving URL patterns within PHP applications.
- [Request Parameter Mapping](https://awesome-repositories.com/f/web-development/request-parameter-mapping.md) — Matches incoming HTTP request paths against defined patterns to extract configuration variables and parameters. ([source](https://cdn.jsdelivr.net/gh/symfony/routing@8.2/README.md))
- [Route Definition Loading](https://awesome-repositories.com/f/web-development/route-definition-loading.md) — Reads route definitions and imports from configuration files to map incoming requests to controllers. ([source](https://symfony.com/doc/current/reference/configuration/framework.html))
- [Route Organization](https://awesome-repositories.com/f/web-development/route-organization.md) — Provides a structured way to organize and group routes using collections and shared prefixes.
- [Route Parameter Validation](https://awesome-repositories.com/f/web-development/route-parameter-validation.md) — Enforces regular expression requirements on path parameters to differentiate between similar routes. ([source](https://symfony.com/doc/current/routing.html))
- [Route Validation](https://awesome-repositories.com/f/web-development/route-validation.md) — Enforces requirements on URL parameters using regular expressions to ensure requests match intended destinations.
- [Static Route Compilers](https://awesome-repositories.com/f/web-development/routing-systems/routing/matching-algorithms/radix-tree-routers/static-route-compilers.md) — Compiles route definitions into optimized PHP code to maximize request matching performance.
- [URL Generators](https://awesome-repositories.com/f/web-development/url-generators.md) — Produces valid absolute or relative URIs by mapping route names and parameters back to path patterns.
- [Custom Route Loaders](https://awesome-repositories.com/f/web-development/custom-route-loaders.md) — Allows the definition of custom loading logic to generate routes from external patterns or conventions. ([source](https://symfony.com/doc/current/routing/custom_route_loader.html))
- [Database-Driven Route Resolution](https://awesome-repositories.com/f/web-development/database-driven-route-resolution.md) — Allows looking up request paths in a database index to handle large volumes of dynamic URLs. ([source](https://symfony.com/doc/current/routing/routing_from_database.html))
- [Database Route Resolution](https://awesome-repositories.com/f/web-development/dynamic-content-resolution/database-route-resolution.md) — Enables high-performance resolution of large volumes of dynamic URLs using a database index.
- [Localized Routing](https://awesome-repositories.com/f/web-development/localized-routing.md) — Defines unique URLs for the same route based on the user's translation locale. ([source](https://symfony.com/doc/current/routing.html))
- [Prefix Groupings](https://awesome-repositories.com/f/web-development/request-routing/path-prefix-matching/prefix-groupings.md) — Allows organizing related route definitions under shared path prefixes to reduce configuration duplication. ([source](https://symfony.com/doc/current/routing.html))
- [JSON Response Formatters](https://awesome-repositories.com/f/web-development/response-formatting/json-response-formatters.md) — Encodes data into JSON format and automatically sets the appropriate application/json content type header. ([source](https://symfony.com/doc/current/controller.html))
- [Routing Configurations](https://awesome-repositories.com/f/web-development/routing-configurations.md) — Provides command line tools to list registered routes and simulate URL matching for debugging. ([source](https://symfony.com/doc/current/routing.html))
- [Path Parameter Converters](https://awesome-repositories.com/f/web-development/routing-systems/routing/parameter-handling-utilities/path-parameter-converters.md) — Transforms route parameter values into database objects or enumerations before they reach the controller. ([source](https://symfony.com/doc/current/routing.html))
- [Route Parameter Captures](https://awesome-repositories.com/f/web-development/routing-systems/routing/parameter-handling-utilities/route-parameter-captures.md) — Defines optional path parameters with default values so routes match even when parameters are omitted. ([source](https://symfony.com/doc/current/routing.html))
- [URL Redirections](https://awesome-repositories.com/f/web-development/url-routing/redirection-rules/geographic-redirection/url-redirections.md) — Provides mechanisms to forward requests to different URLs using defined redirection rules. ([source](https://symfony.com/doc/current/components/http_foundation.html))

### Development Tools & Productivity

- [Regex Path Matchers](https://awesome-repositories.com/f/development-tools-productivity/path-matching-tools/regex-path-matchers.md) — Uses regular expressions to match incoming request paths and extract dynamic URL parameters.
- [Environment Configuration Management](https://awesome-repositories.com/f/development-tools-productivity/environment-configuration-management.md) — Loads different configuration sets based on the active environment to vary behavior between development and production. ([source](https://symfony.com/doc/current/configuration.html))
- [Environment Variable Mapping](https://awesome-repositories.com/f/development-tools-productivity/environment-variable-mapping.md) — References system environment variables at runtime to handle machine-specific settings without clearing caches. ([source](https://symfony.com/doc/current/configuration.html))

### Networking & Communication

- [Request Matching](https://awesome-repositories.com/f/networking-communication/communication-protocols-architectures/request-processing-architectures/request-matching.md) — Evaluates if a request meets specific conditions based on IP, HTTP method, host, or path using matcher classes. ([source](https://symfony.com/doc/current/components/http_foundation.html))
- [HTTP Cache Policies](https://awesome-repositories.com/f/networking-communication/http-cache-policies.md) — Provides configurations for expiration and validators to optimize HTTP content delivery. ([source](https://symfony.com/doc/current/components/http_foundation.html))
- [Route Parameter Validations](https://awesome-repositories.com/f/networking-communication/network-addressing/url-normalizers/url-validations/route-parameter-validations.md) — Enforces strict requirement checks on route parameters to ensure the resulting generated URIs are valid. ([source](https://symfony.com/doc/current/reference/configuration/framework.html))
- [Expression-Based Routing](https://awesome-repositories.com/f/networking-communication/traffic-routing/expression-based-routing.md) — Implements conditional route matching using flexible expression evaluation. ([source](https://symfony.com/doc/current/routing.html))

### Security & Cryptography

- [HTTP Method Restrictions](https://awesome-repositories.com/f/security-cryptography/domain-access-restrictions/request-access-restrictions/controller-method-access-restrictions/http-method-restrictions.md) — Limits the HTTP verbs a specific route responds to and rejects requests using unsupported methods.
- [HTTPS Enforcements](https://awesome-repositories.com/f/security-cryptography/network-infrastructure-security/web-network-security/security-https/https-enforcements.md) — Ensures that generated URLs use HTTPS and automatically redirects insecure HTTP requests to their secure counterparts. ([source](https://symfony.com/doc/current/routing.html))
- [URI Signing](https://awesome-repositories.com/f/security-cryptography/uri-signing.md) — Implements cryptographic signing of URLs to ensure link integrity and enforce expiration timestamps. ([source](https://symfony.com/doc/current/routing.html))

### Software Engineering & Architecture

- [Conditional Route Matching](https://awesome-repositories.com/f/software-engineering-architecture/access-rules/boolean-access-expressions/conditional-route-matching.md) — Evaluates request attributes and boolean expressions to determine if a route matches based on runtime context.
- [Automatic Dependency Resolution](https://awesome-repositories.com/f/software-engineering-architecture/automatic-dependency-resolution.md) — Injects required services into constructors or methods automatically by reading type-hints. ([source](https://symfony.com/doc/current/service_container/autowiring.html))
- [Configuration Injection](https://awesome-repositories.com/f/software-engineering-architecture/configuration-injection.md) — Passes defined configuration values into controllers and services via constructor injection or helper methods. ([source](https://symfony.com/doc/current/configuration.html))
- [Dependency Autowiring](https://awesome-repositories.com/f/software-engineering-architecture/dependency-autowiring.md) — Populates typed properties and calls methods with dependencies using markers to indicate requirements. ([source](https://symfony.com/doc/current/service_container/autowiring.html))
- [Interface-to-Implementation Bindings](https://awesome-repositories.com/f/software-engineering-architecture/interface-to-implementation-bindings.md) — Binds specific service implementations to interfaces to resolve ambiguity when multiple classes implement the same type. ([source](https://symfony.com/doc/current/service_container/autowiring.html))
- [Stateless Request Processing](https://awesome-repositories.com/f/software-engineering-architecture/stateless-request-processing.md) — Prevents session usage during request matching to keep responses cacheable and independent of user state. ([source](https://symfony.com/doc/current/routing.html))

### Part of an Awesome List

- [Sub-Domain Routing](https://awesome-repositories.com/f/awesome-lists/devtools/regex-and-pattern-matching/domain-pattern-matching/domain-keyword-matchers/domain-and-keyword-routing/sub-domain-routing.md) — Matches incoming HTTP hosts against specific values or patterns to trigger appropriate route matches. ([source](https://symfony.com/doc/current/routing.html))

### Data & Databases

- [HTTP Cache Headers](https://awesome-repositories.com/f/data-databases/performance-caching-systems/page-caching-controls/http-cache-headers.md) — Manages HTTP headers to define expiration and validation for browser and proxy caching. ([source](https://symfony.com/doc/current/http_cache.html))

### DevOps & Infrastructure

- [Configuration File Loading](https://awesome-repositories.com/f/devops-infrastructure/configuration-management/file-based-configuration/configuration-file-loading.md) — Provides mechanisms for scanning and parsing structured configuration files like YAML, XML, and PHP arrays. ([source](https://symfony.com/doc/current/configuration.html))
- [Dynamic Configuration Expressions](https://awesome-repositories.com/f/devops-infrastructure/dynamic-configuration-expressions.md) — Parses strings with literals and operators to determine values dynamically based on runtime context. ([source](https://symfony.com/doc/current/reference/formats/expression_language.html))

### Programming Languages & Runtimes

- [Controller Response Serializers](https://awesome-repositories.com/f/programming-languages-runtimes/block-value-returns/method-return-values/return-value-transformers/controller-response-serializers.md) — Automatically converts controller return objects or arrays into the requested response format using a serializer. ([source](https://symfony.com/doc/current/controller.html))
