FOSRestBundle
FOSRestBundle copied to clipboard
Deprecation message when RESTful routes are loaded in Symfony 4.4
I'm getting the following depreciation message on my Symfony 4.4 installation:
Loading the file "../src/Controller/ApiPartner" from the global resource directory "/shinra/narvick/src" is deprecated since Symfony 4.4 and will be removed in 5.0.
I setup a vanilla Symfony install and added only this route, still getting the depreciation. It only shows up once after a cache refresh - after the cache is warmed up, it doesn't seem to trigger anymore.
I included some quick steps to reproduce below.
Steps to reproduce:
-
Install Symfony 4.4 and FOSRestBundle
-
Add to config/routes.yaml file:
api_partner:
type: rest # This resource will have RESTful routes
resource: '../src/Controller/ApiPartner'
name_prefix: partner_api_ # RestBundle-specific prefixes are allowed now, as the RestBundle is now processing routes
- Create src/Controller/ApiPartner/PlayerController.php:
<?php
namespace App\Controller\ApiPartner;
use FOS\RestBundle\Controller\AbstractFOSRestController;
use FOS\RestBundle\Controller\Annotations\Get;
class PlayerController extends AbstractFOSRestController
{
/**
* @Get("/partner/v1/find-player/{username}", name="_find"))
* @Get("/partner/v1/player/{masterPlayerId}")
*/
public function getPlayerAction()
{
return ['success' => false, 'message' => 'This user is not in our database'];
}
}
- Clear cache
php bin/console cache:clear --no-warmup && php bin/console cache:warmup
- Access app in browser, should get the depreciation message above on first load.
Which version of FOSRestBundle did you use? Can create a small example application that allows to reproduce?
This is on 2.7.4. I included the steps to reproduce above but here is a copy of the code also: https://github.com/relm/narvick
Thank you, I can reproduce it. 👍
Related: https://github.com/FriendsOfSymfony/FOSRestBundle/issues/2132
I looked a bit more into this and I am honestly not sure if and how we could fix this. And given the fact that we will deprecate the automatic route generation feature in 2.8 and then remove it in 3.0 I think I won't spend much time on this.
By the way, if you still would like to use the automatic route generation feature, there is a new bundle which will maintain the code from FOSRestBundle that is removed in 3.0 in the new RestRoutingBundle.
/cc @alexander-schranz this issue report might be interesting for you when maintaining RestRoutingBundle to not break on Symfony 5 (specifically HttpKernel 5.0+).