There is no license information available for the latest version (1.0.0) of this package.

Service and command for checking that your Symfony routes are valid

1.0.0 2016-06-11 20:48 UTC

This package is not auto-updated.

Last update: 2020-09-18 19:20:37 UTC


This library provides a service and command for checking if the routes in your router configuration are valid.


Add the package to your dependencies:

composer require amyboyd/symfony-router-validation

Add these lines to your services configuration (e.g. in services.yml or config.yml):

        class: AmyBoyd\SymfonyStuff\RouterValidation\RouterValidationCommand
            -  { name: console.command }

        class: AmyBoyd\SymfonyStuff\RouterValidation\RouterValidationService
            controllerNameParser: '@controller_name_converter'
            container: '@service_container'

To check your routes are valid from the command line:

  • In Symfony 2.*, run app/console router:validate
  • In Symfony 3.*, run bin/console router:validate


To set up for local development:

git clone
cd symfony-router-validation

To verify your installation is working correctly, run the tests:


The tests are run against multiple versions of Symfony (currently 2.5, 2.8, 3.0 and 3.1).

Sample output

3 valid routes
6 invalid routes
app_invalid_controller_because_bundle_does_not_exist - Bundle "InvalidBundle" (from the _controller value "InvalidBundle:Default:index") does not exist, or is it not enabled
app_invalid_controller_because_of_trailing_action - Method "indexActionAction" does not exist in class "AppBundle\Controller\DefaultController".
app_invalid_controller_because_class_does_not_exist - The _controller value "AppBundle:InvalidClass:index" maps to a "AppBundle\Controller\InvalidClassController" class, but this class was not found. Create this class or check the spelling of the class and its namespace.
app_invalid_service_because_service_doesnt_exist - You have requested a non-existent service "app.invalid_controller_service". Did you mean this: "app.controller_service"?
app_invalid_service_because_method_doesnt_exist - Method "invalidMethodAction" does not exist in class "AppBundle\Controller\DefaultController".
app_invalid_missing_controller - _controller property is not set.
2 routes are in a format not supported by this command  - Please report the details at
app_invalid_route_format - Route format "blabla!£%" is not supported by this tool
app_invalid_route_format_2 - Route format "AppBundleDefault@" is not supported by this tool

How to use in continuous integration testing or a Git pre-commit hook

The command returns exit code 0 if all routes are valid, and 1 if there are any invalid routes. You can use this in continuous integration testing or a Git pre-commit hook as follows:

app/console router:validate # or bin/console in Symfony 3
if [[ $? != '0' ]]; then
    exit 1