EasyAdminBundle
EasyAdminBundle copied to clipboard
Route definitions in read-only file systems
Describe the bug
On our system we use Debian packages to deploy our software. So we try to use the Debian file system structure as much as possible. As a result we have changed the cache, build and log directory of our Symfony application. In a standard Symfony application the build and cache directory are mostly the same. Our cache directory lives in /var/cache/...
and our build directory lives together with the source code in /usr/share/...
which is considered read-only (written only from the content of Debian packages). Our application does not have any write permissions in /usr/share/...
.
We use EasyAdmin in version 4.10.1 and encountered a problem with the route definitions which live in var/cache/easyadmin
. This file is generated by the CacheWarmer during the build process in the pipeline but does use the cache directory instead of the build directory by default. Even though routing definition should not change after deployment.
Our workaround is a decorated CacheWarmer which uses the build directory if defined. Additionally, the AdminContextFactory service definition is overridden by a compiler pass to change the cache directory in the first argument to the build directory.
I am not sure whether the change to use the build directory instead of the cache directory is considered a breaking change. If the build directory is not explicitly configured, Symfony uses the cache directory by default. If it is, then this could be an issue for the next major release.
To Reproduce Configure a separate build directory with no write permissions for the web application itself.
Additional context
- "{"message":"Uncaught PHP Exception RuntimeException: \"The name of the route associated to \"Application\\Controller\\DashboardController::index\" cannot be determined. Clear the application cache to run the EasyAdmin cache warmer, which generates the needed data to find this route.\" at AdminContextFactory.php line 89","context":{"exception":{"class":"RuntimeException","message":"The name of the route associated to \"Application\\Controller\\DashboardController::index\" cannot be determined. Clear the application cache to run the EasyAdmin cache warmer, which generates the needed data to find this route.","code":0,"file":"/usr/share/application/app/vendor/easycorp/easyadmin-bundle/src/Factory/AdminContextFactory.php:89"}},"level":500,"level_name":"CRITICAL","channel":"request","datetime":"2024-05-22T15:50:50.258683+02:00","extra":{"uid":"4729330"}}\n"