Skip to content

xp-forge/web-compression

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Web compression

Build status on GitHub XP Framework Module BSD Licence Requires PHP 7.4+ Supports PHP 8.0+ Latest Stable Version

HTTP compression for the XP Framework, implemented as filter.

Example

The following shows how to enable on-the-fly compression for HTTP responses. Depending on the Accept-Encoding header the client sends, the server-supported compression algorithms and the length of the content, the response is compressed, saving bandwidth.

use web\{Application, Filters};
use web\filters\CompressResponses;

class Service extends Application {

  public function routes() {
    return new Filters([new CompressResponses()], function($req, $res) {
      $content= /* ... */;

      $res->answer(200);
      $res->send($content, 'text/html; charset=utf-8');
    });
  }
}

Releases

No releases published

Packages

No packages published

Languages