Middleware to implement Cross-Origin Resource Sharing (CORS)

v1.1.0 2018-08-04 10:41 UTC


Latest Version on Packagist Software License Build Status Quality Score Total Downloads SensioLabs Insight

Middleware to implement Cross-Origin Resource Sharing (CORS) using neomerx/cors-psr7.



This package is installable and autoloadable via Composer as middlewares/cors.

composer require middlewares/cors


use Neomerx\Cors\Strategies\Settings;
use Neomerx\Cors\Analyzer;

$settings = new Settings();
$settings->setServerOrigin('http', 'example.com', 123);

$analyzer = Analyzer::instance($settings);

$dispatcher = new Dispatcher([
	new Middlewares\Cors($analyzer)

$response = $dispatcher->dispatch(new ServerRequest());


__construct(Neomerx\Cors\Contracts\AnalyzerInterface $analyzer)

The CORS analyzer used. See neomerx/cors-psr7 for more info.

responseFactory(Psr\Http\Message\ResponseFactoryInterface $responseFactory)

A PSR-17 factory to create the responses.

Please see CHANGELOG for more information about recent changes and CONTRIBUTING for contributing details.

The MIT License (MIT). Please see LICENSE for more information.