Http2Pusher
1.0.0
PHP HTTP2 Server Pusher
HTTP/2 Push อนุญาตให้เว็บเซิร์ฟเวอร์ส่งทรัพยากรไปยังเว็บเบราว์เซอร์ก่อนที่เบราว์เซอร์จะขอ ส่วนใหญ่เป็นเทคนิคการแสดงที่สามารถช่วยให้บางเว็บไซต์โหลดได้เร็วขึ้น - วิกิพีเดีย
ภาพโดย CloudFlare
การใช้นักแต่งเพลง: composer require melbahja/http2-pusher
รับอินสแตนซ์:
require ' vendore/autoload.php ' ;
use Melbahja Http2 Pusher ;
$ pusher = Pusher:: getInstance ();ตัวอย่าง:
// set css file
$ pusher -> link ( ' /assets/css/style.css ' );
// set css and image and src
$ pusher -> link ( ' /asstes/css/main.css ' )
-> src ( ' /assets/js/scripts.js ' )
-> img ( ' /assets/img/logo.png ' )
- set (Pusher:: IMG , ' /assets/img/logo2.png ' );
// set link with options
$ pusher -> link ( ' https://fonts.gstatic.com ' , [
' as ' => false ,
' rel ' => ' preconnect '
]);
// rel by default is preload
// as by default is the link type
// push header
$ pusher -> push (); Pusher::getInstance(): PusherInterface
Pusher::link(string $link, array $opts = []): PusherInterface
Pusher::src(string $link, array $opts = []): PusherInterface
Pusher::img(string $link, array $opts = []): PusherInterface
Pusher::set(string $type, string $link, array $opts = []): PusherInterface
Pusher::getHeader(string $type = null): string
Pusher::push(string $type = null): void
Pusher::public function toHeader(string $type, array $urls): null|string
MIT Copyright (C) 2017 Mohamed Elbahja