Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

melbahja/Http2Pusher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

9 Commits

Repository files navigation

Http2Pusher

PHP Http2 Server Pusher

About Http2 Server Push :

HTTP/2 Push allows a web server to send resources to a web browser before the browser gets to request them. It is, for the most part, a performance technique that can help some websites load faster. - wikipedia

http2 image by cloudflare

Installation :

using composer: composer require melbahja/http2-pusher

Usage :

get the instance:

require 'vendore/autoload.php';
use Melbahja\Http2\Pusher;
$pusher = Pusher::getInstance();

examples:

// 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();

Public methods :

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

License :

MIT Copyright (c) 2017 Mohamed Elbahja

About

PHP Http2 Server Push

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

Languages

AltStyle によって変換されたページ (->オリジナル) /