8000 minor #10347 Added docs for different protocols as asset base_url (al… · symfony/symfony-docs@2a32351 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2a32351

Browse files
committed
minor #10347 Added docs for different protocols as asset base_url (alexander-schranz)
This PR was merged into the master branch. Discussion ---------- Added docs for different protocols as asset base_url Documentation for: symfony/symfony#28476 Commits ------- 324ad72 Added docs for different protocols as asset base_url
2 parents 2121344 + 324ad72 commit 2a32351

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

components/asset.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,35 @@ document inside a template::
372372
echo $packages->getUrl('resume.pdf', 'doc');
373373
// result: /somewhere/deep/for/documents/resume.pdf?v1
374374

375+
Local files and other protocols
376+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
377+
378+
In cases of e.g. generating a pdf from html you want directly link to the local file for performance reason you can use the asset component the following way:
379+
380+
use Symfony\Component\Asset\UrlPackage;
381+
// ...
382+
383+
$localPackage = new UrlPackage(
384+
'file:///path/to/images/',
385+
new EmptyVersionStrategy()
386+
);
387+
388+
echo $localPackage->getUrl('/logo.png');
389+
// result: file:///path/to/images/logo.png
390+
391+
Or link to a file on a ftp server:
392+
393+
use Symfony\Component\Asset\UrlPackage;
394+
// ...
395+
396+
$ftpPackage = new UrlPackage(
397+
'ftp://example.com/images/',
398+
new EmptyVersionStrategy()
399+
);
400+
401+
echo $ftpPackage->getUrl('/logo.png');
402+
// result: ftp://example.com/images/logo.png
403+
375404
Learn more
376405
----------
377406

0 commit comments

Comments
 (0)
0