FOSRestBundle icon indicating copy to clipboard operation
FOSRestBundle copied to clipboard

Deprecation message when RESTful routes are loaded in Symfony 4.4

Open relm opened this issue 5 years ago • 7 comments

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:

  1. Install Symfony 4.4 and FOSRestBundle

  2. 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
  1. 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'];
    }
}
  1. Clear cache

php bin/console cache:clear --no-warmup && php bin/console cache:warmup

  1. Access app in browser, should get the depreciation message above on first load.

relm avatar May 07 '20 04:05 relm

Which version of FOSRestBundle did you use? Can create a small example application that allows to reproduce?

xabbuh avatar May 07 '20 06:05 xabbuh

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

relm avatar May 07 '20 06:05 relm

Thank you, I can reproduce it. 👍

xabbuh avatar May 07 '20 06:05 xabbuh

Related: https://github.com/FriendsOfSymfony/FOSRestBundle/issues/2132

W0rma avatar May 07 '20 11:05 W0rma

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.

xabbuh avatar May 07 '20 18:05 xabbuh

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.

xabbuh avatar May 09 '20 09:05 xabbuh

/cc @alexander-schranz this issue report might be interesting for you when maintaining RestRoutingBundle to not break on Symfony 5 (specifically HttpKernel 5.0+).

xabbuh avatar May 09 '20 09:05 xabbuh