symfony/web-link
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
psr/link | 2.0.1 | 5.66 kB | MIT | prod |
The Symfony/WebLink component is designed to manage links between resources for your PHP development. In particular, it serves to advise your clients to preload and prefetch documents via HTTP and HTTP/2 pushes. This component supports the HTML5's Links, Preload, and Resource Hints W3C's specifications. It can also integrate with extensions as defined in the HTML5 link type extensions wiki.
In order to use Symfony/WebLink in your PHP project, first, install it via composer with the command: $ composer require symfony/web-link
. Then, you can utilize the component in your PHP code. Here is an example:
use Symfony\Component\WebLink\GenericLinkProvider;
use Symfony\Component\WebLink\HttpHeaderSerializer;
use Symfony\Component\WebLink\Link;
$linkProvider = (new GenericLinkProvider())
->withLink(new Link('preload', '/bootstrap.min.css'));
header('Link: '.(new HttpHeaderSerializer())->serialize($linkProvider->getLinks()));
echo 'Hello';
This example shows how you to use Symfony/WebLink to serialize a HTTP header link with the preload link relation type and the target URI being '/bootstrap.min.css'. This instructs the browser to preload the bootstrap stylesheet.
Comprehensive documentation and guidance on the Symfony/WebLink are available on the official Symfony Documentation site. You may access it directly here: Symfony WebLink Documentation. For addressing issues or contributing to further development, you can interact within the main Symfony repository on GitHub.