0
votes

I'm currently updating one of my projects from Symfony2 to Symfony3. Most of the work is done but there is some kind of error I don't understand.

For the routing configuration file, I read the official documentation (http://symfony.com/doc/current/book/routing.html#adding-http-method-requirements) which is telling me to write this configuration :

corbins_characters_new_character:
    path: /characters/new
    defaults: { _controller: CorbinsCharacterBundle:Character:new }
    requirements:
        methods: [GET]

corbins_characters_new_character:
    path: /characters
    defaults: { _controller: CorbinsCharacterBundle:Character:create }
    requirements:
        methods: [POST]

But when I do, I have the following error :

Routing requirement for "methods" must be a string in C:\Developpement\Symfony2\Corbins_V3\src\Corbins\CharacterBundle/Resources/config/routing.yml (which is being imported from "C:\Developpement\Symfony2\Corbins_V3\app/config\routing.yml").

InvalidArgumentException: Routing requirement for "methods" must be a string.
 - in vendor\symfony\symfony\src\Symfony\Component\Routing\Route.php at line 571

I was going to create a new issue for Symfony but first I want to ask for help here :D !

Any idea ?

1
Are you sure that this error is triggered by that route? The exception should only be triggered when the requirements key is parsed (which isn't present in your example route).xabbuh
@xabbuh : I'm going to edit my post to let you see my whole file and the whole error !Kern
@Federico : Yes I did :) !Kern

1 Answers

3
votes

In Doc it says methods is not a child of requirements it is just a parent key.

corbins_characters_new_character:
    path: /characters
    defaults: { _controller: CorbinsCharacterBundle:Character:create }
    methods: [POST]

Could you please check http://symfony.com/doc/current/book/routing.html#adding-http-method-requirements with yml configuration.