Symfony Framework Documentation
  • The Quick Tour
  • Getting Started
  • The Symfony Framework Best Practices
  • The Bundle System
  • Cache
  • Console Commands
  • Databases and the Doctrine ORM
  • How to Deploy a Symfony Application
  • Swift Mailer
  • Events and Event Listeners
  • Forms
  • Managing CSS and JavaScript
  • HTTP Cache
  • Logging
  • Sending Emails with Mailer
  • Pushing Data to Clients Using the Mercure Protocol
  • Messenger: Sync & Queued Message Handling
  • Migrating an Existing Application to Symfony
  • Creating and Sending Notifications
  • Performance
  • Profiler
  • Routing
  • Security
  • Sessions
  • Installing & Setting up the Symfony Framework
  • How to Use the Serializer
  • Service Container
  • Testing
  • Translations
  • Validation
  • Asset Preloading and Resource Hints with HTTP/2 and WebLink
  • Workflow
  • The Components
    • How to Install and Use the Symfony Components
    • The Asset Component
    • The BrowserKit Component
    • The Cache Component
    • The ClassLoader Component
    • The Config Component
    • The Console Component
    • The Contracts Component
    • The CssSelector Component
    • The DependencyInjection Component
    • The DomCrawler Component
    • The Dotenv Component
    • The ErrorHandler Component
    • The EventDispatcher Component
    • The ExpressionLanguage Component
    • The Filesystem Component
    • The Finder Component
    • The Form Component
    • The HttpClient Component
    • The HttpFoundation Component
    • The HttpKernel Component
    • The Inflector Component
    • The Intl Component
    • The Ldap Component
    • The Lock Component
    • The Mailer Component
    • The Mercure Component
    • The Messenger Component
    • The Mime Component
    • The OptionsResolver Component
    • The PHPUnit Bridge
    • The Symfony Polyfill / APCu Component
    • The Symfony Polyfill / Ctype Component
    • The Symfony Polyfill / Iconv Component
    • The Symfony Polyfill / Intl Grapheme Component
    • The Symfony Polyfill / Intl ICU Component
    • The Symfony Polyfill / Intl IDN Component
    • The Symfony Polyfill / Intl MessageFormatter Component
    • The Symfony Polyfill / Intl Normalizer Component
    • The Symfony Polyfill / Mbstring Component
    • The Symfony Polyfill / PHP 5.4 Component
    • The Symfony Polyfill / PHP 5.5 Component
    • The Symfony Polyfill / PHP 5.6 Component
    • The Symfony Polyfill / PHP 7.0 Component
    • The Symfony Polyfill / PHP 7.1 Component
    • The Symfony Polyfill / PHP 7.2 Component
    • The Symfony Polyfill / PHP 7.3 Component
    • The Symfony Polyfill / UUID Component
    • The Process Component
    • The PropertyAccess Component
    • The PropertyInfo Component
    • The PSR-7 Bridge
    • The Security Component
    • The Serializer Component
    • The Stopwatch Component
    • The String Component
    • The Templating Component
    • The UID Component
    • The Validator Component
    • The VarDumper Component
    • The VarExporter Component
    • The WebLink Component
      • Installation
      • Usage
    • The Workflow Component
    • The Yaml Component
  • Reference Documents
  • Contributing
  • Create your own PHP Framework
Symfony Framework Documentation
  • Docs »
  • The Components »
  • The WebLink Component
  • View page source

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¶

1
$ composer require symfony/web-link

注釈

If you install this component outside of a Symfony application, you must require the vendor/autoload.php file in your code to enable the class autoloading mechanism provided by Composer. Read this article for more details.

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 WebLink documentation to learn about all the features of the component and its integration with the Symfony framework.

Next Previous

© Copyright .

Built with Sphinx using a theme provided by Read the Docs.