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 All time: 6,493 This week: 673Up
Version License PHP version Categories
http2pusher 1.1Custom (specified...7.1HTTP, PHP 7


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: 72 Up1 in Morocco Morocco Equal
Innovation award
Innovation award
Nominee: 4x



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


// set css file

// set css and image and src
	-set(Pusher::IMG, '/assets/img/logo2.png');

// set link with options
$pusher->link('', [
	'as' => false,
	'rel' => 'preconnect' 

// rel by default is preload
// as by default is the link type 

// push header

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 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  
This week:0
All time:6,493
This week:673Up
 User Ratings  
 All time