-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Closed as not planned
Closed as not planned
Copy link
Labels
Description
Symfony version(s) affected
6.1.5
Description
Current Situation
With $framework->assets()->basePath('/public');
in framework.php
, when using {{ asset('assets/logo.svg') }}
in a Twig template, the outcome is always (i.e. via CLI and via webserver): /public/assets/logo.svg
Needed Behavior
- Since on the web server,
/public
is mapped to/
, the final path in the template needs to be/assets/logo.svg
. - But in a CLI command, the final path needs to be
/public/assets/logo.svg
.
The latest(?) PR regarding this was #36681
My use case: I'm generating PDF's from the same template through web and CLI. And I think that Symfony's current approach (aligning the asset context to the routing context - as far as I understand) will never work in this case, because:
- The solution for generating links from CLI is to use a full URL (that's what
default_uri
is for). - But this doesn't work for assets - you cannot use a full URL as
<img src="">
How to reproduce
See above.
Possible Solution
Maybe create a setting like cli_base_path
that only gets prefixed to asset()
when called from CLI.
Additional Context
No response