tomschlick / laravel-http2-server-push
一个Laravel中间件包,用于启用对脚本、样式和图像资源的服务器推送。
v0.2.1
2018-10-22 15:28 UTC
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-08-26 06:09:42 UTC
README
一个用于Laravel 5 / Lumen的中间件包,用于启用脚本、样式和图像资源的服务器推送。
安装
首先将包添加到您的composer.json文件中
composer require tomschlick/laravel-http2-server-push
然后向您的config/app.php文件中添加服务提供者
\TomSchlick\ServerPush\ServiceProvider::class,
然后将中间件添加到您的Http Kernel (app/Http/Kernel.php)文件中。在列表末尾添加。
protected $middleware = [ \TomSchlick\ServerPush\Http2ServerPushMiddleware::class, ];
使用方法
现在,当您在路由上启用它时,它将自动将资源包含在您的elixir /build/rev-manifest.json文件中。您可以从项目的任何位置手动添加资源,使用pushStyle($pathOfCssFile),pushScript($pathOfJsFile),pushFont($pathOfFontFile)或pushImage($pathOfImageFile)。