class UrlPackage extends Package
Package that adds a base URL to asset URLs in addition to a version.
The package allows to use more than one base URLs in which case it randomly chooses one for each asset; it also guarantees that any given path will always use the same base URL to be nice with HTTP caching mechanisms.
When the request context is available, this package can choose the best base URL to use based on the current request scheme:
- For HTTP request, it chooses between all base URLs;
- For HTTPs requests, it chooses between HTTPs base URLs and relative protocol URLs or falls back to any base URL if no secure ones are available.
Methods
__construct(string|string[] $baseUrls, VersionStrategyInterface $versionStrategy, ContextInterface $context = null) | ||
string | getVersion(string $path) Returns the asset version for an asset. | from Package |
string | getUrl(string $path) Returns an absolute or root-relative public path. | |
string | getBaseUrl(string $path) Returns the base URL for a path. |
Details
__construct(string|string[] $baseUrls, VersionStrategyInterface $versionStrategy, ContextInterface $context = null)
string getVersion(string $path)
Returns the asset version for an asset.
string getUrl(string $path)
Returns an absolute or root-relative public path.
string getBaseUrl(string $path)
Returns the base URL for a path.
Please login to continue.