PHP Classes
elePHPant
Icontem

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)    
Last Updated Ratings Unique User Downloads Download Rankings
2017-10-21 (29 days ago) RSS 2.0 feedStarStarStarStar 64%Total: 289 This week: 12All time: 7,199 This week: 53Up
Version License PHP version Categories
http2pusher 1.0Custom (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
Nominee
Vote
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.

Manuel Lemos
  Performance   Level  
Name: Mohamed Elbahja is available for providing paid consulting. Contact Mohamed Elbahja .
Classes: 9 packages by
Country: Morocco Morocco
Age: 22
All time rank: 11501 in Morocco Morocco
Week rank: 29 Up1 in Morocco Morocco Equal
Innovation award
Innovation award
Nominee: 3x

Details

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 <small>image by cloudflare</small>

Installation :

using composer: `bash 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:289
This week:12
All time:7,199
This week:53Up
 User Ratings  
 
 All timeMonth
Utility:91%StarStarStarStarStar91%Equal
Consistency:91%StarStarStarStarStar91%Equal
Documentation:91%StarStarStarStarStar91%Equal
Examples:--
Tests:--
Videos:--
Overall:64%StarStarStarStar64%Equal
Rank:8901Up