Skip to content
Permalink
Browse files

Document direct use of PhastDocumentFilters, PhastServices

  • Loading branch information...
apeschar committed Oct 5, 2019
1 parent e961ec1 commit 12f69bf3f07d0553effcda4d98f031dedba3730e
Showing with 16 additions and 11 deletions.
  1. +4 −2 README.md
  2. +1 −1 src/PhastDocumentFilters.php
  3. +11 −2 src/PhastServices.php
  4. +0 −3 src/images.php
  5. +0 −3 src/scripts.php
@@ -32,15 +32,17 @@ Create `http://your.site/phast.php` to serve optimized versions of resources:

~~~php
<?php
require 'vendor/kiboit/phast/src/services.php';
require 'vendor/autoload.php';
\Kibo\Phast\PhastServices::serve();
~~~

Load Phast on all of your pages:

~~~php
<?php
// At the top of your index.php
require 'vendor/kiboit/phast/src/html-filters.php';
require 'vendor/autoload.php';
\Kibo\Phast\PhastDocumentFilters::deploy();
~~~

Test your site!
@@ -21,7 +21,7 @@ class PhastDocumentFilters {
( </body> | </html> )
~xsiA";
public static function deploy(array $userConfig) {
public static function deploy(array $userConfig = []) {
$runtimeConfig = self::configure($userConfig);
if (!$runtimeConfig) {
return;
@@ -14,7 +14,10 @@
class PhastServices {
public static function serve(callable $getConfig) {
/**
* @param callable|null $getConfig
*/
public static function serve(callable $getConfig = null) {
$httpRequest = Request::fromGlobals();
$serviceRequest = ServiceRequest::fromHTTPRequest($httpRequest);
$serviceParams = $serviceRequest->getParams();
@@ -34,7 +37,13 @@ public static function serve(callable $getConfig) {
header('Cache-Control: max-age=86400');
}
$userConfig = new Configuration($getConfig());
if ($getConfig === null) {
$config = [];
} else {
$config = $getConfig();
}
$userConfig = new Configuration($config);
$runtimeConfig = Configuration::fromDefaults()
->withUserConfiguration($userConfig)

This file was deleted.

This file was deleted.

0 comments on commit 12f69bf

Please sign in to comment.
You can’t perform that action at this time.