2017 © Pedro Peláez
 

library symfony-router-validation

Service and command for checking that your Symfony routes are valid

image

amyboyd/symfony-router-validation

Service and command for checking that your Symfony routes are valid

  • Sunday, June 12, 2016
  • by amyboyd
  • Repository
  • 1 Watchers
  • 1 Stars
  • 3,708 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 7 % Grown

The README.md

Symfony router validation

This library provides a service and command for checking if the routes in your router configuration are valid., (*1)

Install

Add the package to your dependencies:, (*2)

composer require amyboyd/symfony-router-validation

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

services:
    amyboyd.command.router_validate_command:
        class: AmyBoyd\SymfonyStuff\RouterValidation\RouterValidationCommand
        tags:
            -  { name: console.command }

    amyboyd.router_validation:
        class: AmyBoyd\SymfonyStuff\RouterValidation\RouterValidationService
        arguments:
            controllerNameParser: '@controller_name_converter'
            container: '@service_container'

To check your routes are valid from the command line:, (*4)

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

Contribute

To set up for local development:, (*5)

git clone git@github.com:amyboyd/symfony-router-validation.git
cd symfony-router-validation
bin/composer-install

To verify your installation is working correctly, run the tests:, (*6)

bin/test
bin/run-validate-command

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

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 https://github.com/amyboyd/symfony-router-validation/issues
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:, (*8)

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

The Versions

12/06 2016

dev-master

9999999-dev https://github.com/amyboyd/symfony-router-validation

Service and command for checking that your Symfony routes are valid

  Sources   Download

The Requires

  • php >=5.4.0

 

by Amy Boyd

11/06 2016

1.0.0

1.0.0.0 https://github.com/amyboyd/symfony-router-validation

Service and command for checking that your Symfony routes are valid

  Sources   Download

The Requires

  • php >=5.4.0

 

by Amy Boyd