PHP code example of middlewares / cors
1. Go to this page and download the library: Download middlewares/cors library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
middlewares / cors example snippets
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());
$analyzer = Analyzer::instance($settings);
$responseFactory = new MyOwnResponseFactory();
$cors = new Middlewares\Cors($analyzer, $responseFactory);