1x: The "controller_name_converter" service is deprecated since Symfony 4.3. It is being referenced by the "fos_rest.routing.loader.controller" service.
1x in JsonControllerTest::setUp from App\Tests\Controller\Api\V1
See #2032
@xabbuh This error started to appear again with dev-master. Previously I fixed it using
fos_rest:
routing_loader:
parse_controller_name: false
but now this option is invalid so I can't suppress it. How do I get rid of it now?
Can you debug where the service is actually used?
It's not easy... Also I'm getting more deprecations now. But I'm not using any of these on purpose so it must be some internal thing in your bundle. What do I need to disable to get rid of them?
1x: The FOS\RestBundle\Routing\RestRouteCollection class is deprecated since FOSRestBundle 2.8.
1x: The FOS\RestBundle\Routing\ClassResourceInterface is deprecated since FOSRestBundle 2.8.
1x: The FOS\RestBundle\Controller\Annotations\NamePrefix annotation is deprecated since FOSRestBundle 2.8.
1x: The FOS\RestBundle\Controller\Annotations\Prefix annotation is deprecated since FOSRestBundle 2.8.
1x: The fos_rest.routing.loader.directory service is deprecated since FOSRestBundle 2.8.
1x: The FOS\RestBundle\Routing\Loader\DirectoryRouteLoader class is deprecated since FOSRestBundle 2.8.
1x: The fos_rest.routing.loader.processor service is deprecated since FOSRestBundle 2.8.
1x: The FOS\RestBundle\Routing\Loader\RestRouteProcessor class is deprecated since FOSRestBundle 2.8.
1x: The fos_rest.routing.loader.controller service is deprecated since FOSRestBundle 2.8.
1x: The FOS\RestBundle\Routing\Loader\RestRouteLoader class is deprecated since FOSRestBundle 2.8.
1x: The fos_rest.routing.loader.reader.controller service is deprecated since FOSRestBundle 2.8.
1x: The FOS\RestBundle\Routing\Loader\Reader\RestControllerReader class is deprecated since FOSRestBundle 2.8.
1x: The fos_rest.routing.loader.reader.action service is deprecated since FOSRestBundle 2.8.
1x: The FOS\RestBundle\Routing\Loader\Reader\RestActionReader class is deprecated since FOSRestBundle 2.8.
1x: The fos_rest.inflector.doctrine service is deprecated since FOSRestBundle 2.8.
1x: Not passing an instance of FOS\RestBundle\Routing\Loader\Reader\RestControllerReader as the 3rd argument of FOS\RestBundle\Routing\Loader\RestRouteLoader::__construct() is deprecated since FOSRestBundle 2.8.
1x: The fos_rest.routing.loader.yaml_collection service is deprecated since FOSRestBundle 2.8.
1x: The FOS\RestBundle\Routing\Loader\RestYamlCollectionLoader class is deprecated since FOSRestBundle 2.8.
1x: The fos_rest.routing.loader.xml_collection service is deprecated since FOSRestBundle 2.8.
1x: The FOS\RestBundle\Routing\Loader\RestXmlCollectionLoader class is deprecated since FOSRestBundle 2.8.
You need to disable the automatic route generation feature:
fos_rest:
routing_loader: false
But what do I use instead?
Symfony\Component\Config\Exception\LoaderLoadException
Cannot load resource "@ApiBundle/Controller". Make sure the "ApiBundle"
bundle is correctly registered and loaded in the application kernel class.
If the bundle is registered, make sure the bundle path "@ApiBundle/Controller"
is not empty.
I'm guessing that the problem now is using type: rest in routing.yml:
api:
resource: '@ApiBundle/Controller'
type: rest
prefix: /crm/api/v{version}
requirements: { version: '\d+\.\d+' }
What should I change this to?
Btw. can you create a 2.8 branch? Master is already 3.0-dev but 2.8 branch doesn't exist...
There won't be any REST-specific loader anymore. You will need to configure the routes explicitly (the method specific annotations @Get, @Post and so on won't be removed and will be handled by Symfony's annotation loader).
If you still would like to use this feature, you will have to wait a bit to be able to use the new FOSRestRoutingBundle @alexander-schranz is currently working on.
Btw. can you create a 2.8 branch? Master is already 3.0-dev but 2.8 branch doesn't exist...
The 2.x branch mirrors the 2.8 development. We set up a branch alias so requiring something like ^2.8@dev will bring you the latest development version of 2.8.
the method specific annotations
@Get,@Postand so on won't be removed and will be handled by Symfony's annotation loader
Does that mean I can simply change type: rest to type: annotation?
Yes, that should work.
Looks like I have to remove @NamePrefix and add the prefix to each route manually.
Does that mean I can simply change type: rest to type: annotation?
@enumag it depends on your controller how did you define it. If you did use the implements ClassResourceInterface which automatically generates routes by the public functions like getAction, postAction, *Action this will not work with the annotation route loader.
This automatic route generation is moved to FOSRestRoutingBundle.
Looks like I have to remove @NamePrefix and add the prefix to each route manually.
Symfony supports the name prefix also in your route definition:
api:
resource: '@ApiBundle/Controller'
type: annotation
prefix: /crm/api/v{version}
requirements: { version: '\d+\.\d+' }
name_prefix: 'api_bundle.'
Most helpful comment
Fixed in https://github.com/FriendsOfSymfony/FOSRestBundle/pull/2074