tomschlick / laravel-http2-server-push
A middleware package for Laravel to enable server push for your script, style, and image assets.
Installs: 63 258
Dependents: 0
Suggesters: 0
Security: 0
Stars: 166
Watchers: 5
Forks: 20
Open Issues: 5
Requires
- php: >=7.0
- illuminate/contracts: ^5.1.
- illuminate/http: ^5.1
- illuminate/support: ^5.1
Requires (Dev)
- graham-campbell/testbench: ^3.1
- phpunit/phpunit: ^5.4
This package is auto-updated.
Last update: 2024-10-26 06:31:58 UTC
README
A middleware package for Laravel 5 / Lumen to enable server push for your script, style, and image assets.
Installation
First start by adding the package to your composer.json file
composer require tomschlick/laravel-http2-server-push
Next add the service provider to your config/app.php
file:
\TomSchlick\ServerPush\ServiceProvider::class,
Then add the middleware to your Http Kernel (app/Http/Kernel.php
). Do so towards the end of the list.
protected $middleware = [ \TomSchlick\ServerPush\Http2ServerPushMiddleware::class, ];
Usage
Now when you enable it on a route it will automatically include the resources in your elixir /build/rev-manifest.json
file.
To add a resource manually you may use pushStyle($pathOfCssFile)
, pushScript($pathOfJsFile)
, pushFont($pathOfFontFile)
or pushImage($pathOfImageFile)
from anywhere in your project.