/CorsSlim

CORS Middleware for PHP Slim Framework

Primary LanguagePHPMIT LicenseMIT

Cross-origin resource sharing (CORS) Middleware for PHP Slim Framework.

Usage

<?php
\Slim\Slim::registerAutoLoader();

$app = new \Slim\Slim();

require ('path_to_your_middlewares/CorsSlim.php');
$app->add(new \CorsSlim\CorsSlim());
?>

Options

You can create the middleware with custom options. Pass options as associative array.

Example

$corsOptions = array(
    "origin" => "*",
    "exposeHeaders" => array("X-My-Custom-Header", "X-Another-Custom-Header"),
    "maxAge" => 1728000,
    "allowCredentials" => True,
    "allowMethods" => array("POST, GET"),
    "allowHeaders" => array("X-PINGOTHER")
    );
$cors = new \CorsSlim\CorsSlim($corsOptions);

License

MIT