PHP Classes

HTTP2 Server Push PHP Class: Push Web resources using HTTP 2 requests

Recommend this page to a friend!
  Info   View files Documentation   View files View files (8)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 64%Total: 409 This week: 2All time: 6,491 This week: 96Up
Version License PHP version Categories
http2pusher 1.1Custom (specified...7.1HTTP, PHP 7
Description 

Author

This class can push Web resources using HTTP 2 requests.

It can send HTTP response headers to the browser to list resources that the page needs so the browser can pull those resources even before the whole Web page is loaded using parallel HTTP/2 requests.

Currently it can push Web resources like images, CSS and JavaScript files.

Innovation Award
PHP Programming Innovation award nominee
October 2017
Number 2
HTTP/2 is a newer version of the HTTP protocol that can make sites much faster by serving many of the resources a page needs by delivering them simultaneously to the user browser.

This class makes it easier to use HTTP/2 server push feature to take advantage of the speed gains when serving a PHP Web site page when it is running on a HTTP/2 server.

Manuel Lemos
Picture of Mohamed Elbahja
  Performance   Level  
Name: Mohamed Elbahja is available for providing paid consulting. Contact Mohamed Elbahja .
Classes: 12 packages by
Country: Morocco Morocco
Age: 29
All time rank: 9041 in Morocco Morocco
Week rank: 106 Up1 in Morocco Morocco Equal
Innovation award
Innovation award
Nominee: 4x

Documentation

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


  Files folder image Files  
File Role Description
Files folder imagesrc (3 files)
Files folder imagetests (1 file)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  src  
File Role Description
  Plain text file Pusher.php Class Class source
  Plain text file PusherException.php Class Class source
  Plain text file PusherInterface.php Class Class source

  Files folder image Files  /  tests  
File Role Description
  Plain text file PusherTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:409
This week:2
All time:6,491
This week:96Up
 User Ratings  
 
 All time
Utility:91%StarStarStarStarStar
Consistency:91%StarStarStarStarStar
Documentation:91%StarStarStarStarStar
Examples:-
Tests:-
Videos:-
Overall:64%StarStarStarStar
Rank:748