Skip to content

zmarquez/stackphp-ampcors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

AMP CORS middleware for StackPHP

This package contains a StackPHP middleware that manages the AMP security CORS requests.

Options

The AmpCorsMiddleware accepts an array of options:

  • publisherOrigin: contains the value of the source origin.
  • queryString: array with parameters to add of the request.

Example

<?php

use Zmc\Stack\AmpCorsMiddleware;

require_once __DIR__ . '../vendor/autoload.php';

$app = new Silex\Application();

$stack = (new Stack\Builder())
    ->push(
        AmpCorsMiddleware::class,
        [
            'publisherOrigin' => 'https://example.com',
            'queryString' => [
                'lang' => 'es'
            ]
        ]);

$app = $stack->resolve($app);

$request = Request::createFromGlobals();
$response = $app->handle($request)->send();

$app->terminate($request, $response);

Installation

The recommended way to install AmpCorsMiddleware is through Composer:

{
    "require": {
        "zmarquez/stackphp-ampcors": "dev-master"
    }
}