Skip to content

Latest commit

 

History

History
41 lines (27 loc) · 1.18 KB

web_link.rst

File metadata and controls

41 lines (27 loc) · 1.18 KB
.. index::
   single: WebLink
   single: Components; WebLink

The WebLink Component

The WebLink component provides tools to manage the Link HTTP header needed for Web Linking when using HTTP/2 Server Push as well as Resource Hints.

Installation

$ composer require symfony/web-link

Usage

The following example shows the component in action:

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';

Read the full :doc:`WebLink documentation </web_link>` to learn about all the features of the component and its integration with the Symfony framework.