New in Symfony 3.4: Default request context for assets
Generating URLs in a command console is tricky because the console context
doesn't know anything about HTTP requests, virtual hosts and domain names. This
means that generating an absolute URL in a console command will always use
http://localhost as the host name.
Symfony solves this problem with the
which define the hostname, HTTP scheme and base URL for console commands. When
generating asset URLs with the
asset() function in a command, the same
For example, if your application is installed in a subdirectory and have configured this parameter:
# app/config/parameters.yml router.request_context.base_url: '/subfolder'
A call to
asset('/foo/image.jpg') will result in
instead of the expected
That's why in Symfony 3.4 we've introduced two new parameters called
define the default request context for assets. In this same application, if you
define this new parameter:
# app/config/parameters.yml asset.request_context.base_path: '/subfolder'
asset('/foo/image.jpg') function will generate the expected
Comments are closed.
To ensure that comments stay relevant, they are closed for old posts.