PHP code example of compwright / psr-cors

1. Go to this page and download the library: Download compwright/psr-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/ */

    

compwright / psr-cors example snippets




use Compwright\PsrCors\Middleware;

$middleware = Middleware::create(
    responseFactory: $psrResponseFactory,
    allowedHeaders: ['x-allowed-header', 'x-other-allowed-header'],    
    allowedMethods: ['DELETE', 'GET', 'POST', 'PUT'],
    allowedOrigins: ['localhost'],
    exposedHeaders: [],
    maxAge: 600,
    supportsCredentials: false
);

$response = $middleware->handle($request, $app);