0

I am basically following this tutorial: http://welcometothebundle.com/symfony2-rest-api-the-best-2013-way/

I already have created my first controller but as soon as I start adding the route: routing.yml

strego_user_controller:
    resource: "@StregoUserBundle/Controller"
    type:     annotation


strego_user_rest: 
    type: rest 
    prefix: /api 
    resource: "@StregoUserBundle/Resources/config/rest_routing.yml"

rest_routing.yml

strego_user_rest_groups:
    type:   rest
    prefix: /v1
    resource: "Strego/UserBundle/Controller/UserGroupRestController"
    name_prefix: api_1_

When I now do a cache:clear I get following exception:

Cannot redeclare class Strego\UserBundle\Controller\UserGroupRestController in /Users/marc/Sites/gambify/src/Strego/UserBundle/Controller/UserGroupRestController.php on line 33

which is ultimately caused by:

.......
PHP  28. FOS\RestBundle\Routing\Loader\RestRouteLoader->getControllerLocator() /Users/marc/Sites/gambify/vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/Routing/Loader/RestRouteLoader.php:77
PHP  29. class_exists() /Users/marc/Sites/gambify/vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/Routing/Loader/RestRouteLoader.php:119
PHP  30. Composer\Autoload\ClassLoader->loadClass() /Users/marc/Sites/gambify/vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/Routing/Loader/RestRouteLoader.php:0
PHP  31. Composer\Autoload\includeFile() /Users/marc/Sites/gambify/vendor/composer/ClassLoader.php:269

I don't know how to avoid this.

m0c
  • 2,180
  • 26
  • 45

1 Answers1

0

The issue was related due to the / and \ in my class. Somehow the call if the class exist was false but the path resulution worked, so the file with the class definition was included twice.

m0c
  • 2,180
  • 26
  • 45