symfony: [FrameworkBundle] Unable to remove deprecation notice in FileLocator?
Symfony version(s) affected: 4.4.0
Description
When running our test suite we saw this deprecation notice:
2x: Loading the file "../src/UI/Http/Web/Controller/" from the global resource directory "/app/src" is deprecated since Symfony 4.4 and will be removed in 5.0.
…that we can’t really remove, the FrameworkBundle is injecting the $paths parameter to the FileLocator service and our routes.yaml resource, configured this way according to the docs:
web_controllers:
resource: '../src/UI/Http/Web/Controller/'
type: annotation
…is the one triggering this notification. AFAIK, this way of configuring the routes with relative paths is still the recommended way, but the deprecation notice seems to trigger whenever there’s a non-absolute path being loaded, even though it doesn’t use the deprecated $paths variable in order to be located, which I believe is a little bit too extreme?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 25 (17 by maintainers)
@relm You might have the same misconfiguration that I had: a routing file in a subdirectory of
config(eg:config/routes/foo.yaml) that references a directory or a file ofsrcrelatively but that misses a..(eg:../src/Controller/Fooinstead of../../src/Controller/Foo).In this case, the file is still found by the
FileLocatorbut only thanks to the global resource directorysrc. The fact that the message mentionsResourcesis a bug that is misleading but it will be resolved by https://github.com/symfony/symfony/pull/35269. But the deprecation should still be triggered, your code is probably the problem here.Thanks, I am able to reproduce it now. Looking into it.
I get this deprecation as soon as Symfony 4.4 is installed, I don’t really understand how this went unnoticed. I’ve “fixed” it too just by adding an asterisk at the end of the resource line in
annotations.yaml.Before:
After:
I think #34886 should solve this.
@xabbuh yes it does, just start the symfony server
symfony serveand load the initial page, then go to the web toolbar to see the deprecations triggered and you will see it