2017 © Pedro Peláez
 

library cors

PHP CORS (Cross-origin resource sharing) middleware.

image

medz/cors

PHP CORS (Cross-origin resource sharing) middleware.

  • Tuesday, July 3, 2018
  • by medz
  • Repository
  • 8 Watchers
  • 132 Stars
  • 4,211 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 10 Forks
  • 3 Open issues
  • 12 Versions
  • 118 % Grown

The README.md

CORS

PHP Composer StyleCI Build Status FOSSA Status, (*1)

PHP CORS (Cross-origin resource sharing) middleware., (*2)

Support

Using

composer require medz/cors

Example:, (*3)

use Medz\Cors\Cors;

$cors = new Cors($config); // The $config 👉 `config/cors.php` file.
$cors->setRequest($requestType, $request); // The $request is empty array or is `NULL` or $_REQUEST
$cors->setResponse($responseType, $response); // The $response is empty array.
$cors->handle();

$response = $cors->getResponse();

Both $requestType and $responseType are of any type that is individually set to support, but if used in a framework, these two values are usually the same. Because you can set it up individually, you can deliver different values depending on your needs to achieve your goals., (*4)

Configure

The config example:, (*5)

$config = [
    'allow-credentials' => false, // set "Access-Control-Allow-Credentials" 👉 string "false" or "true".
    'allow-headers'      => ['*'], // ex: Content-Type, Accept, X-Requested-With
    'expose-headers'     => [],
    'origins'            => ['*'], // ex: http://localhost
    'methods'            => ['*'], // ex: GET, POST, PUT, PATCH, DELETE
    'max-age'            => 0,
];

Array

use Medz\Cors\Cors;

$cors = new Cors($config);
$cors->setRequest('array', $request);
$cors->setResponse('array', $response);
$cors->handle();

$responseHeadersArray = $cors->getResponse();

PSR-7

use Medz\Cors\Cors;

$cors = new Cors($config);
$cors->setRequest('psr-7', $request);
$cors->setResponse('psr-7', $response);

$response = $cors->getResponse();

Other

Because of the interface features provided by this package, you can implement it in a small amount of code in any other framework., (*6)

Excellent Repositories

License

The component is open-sourced software licensed under the MIT license., (*7)

FOSSA Status, (*8)

The Versions

03/07 2018

dev-master

9999999-dev

PHP CORS (Cross-origin resource sharing) middleware.

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

laravel middleware psr-7 cors php yii2 symfony request thinkphp response slim laravel5 crossdomain psr-15 php-cors cors-request

15/05 2018

v1.3.1

1.3.1.0

PHP CORS (Cross-origin resource sharing) middleware.

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

09/05 2018

v1.3.0

1.3.0.0

PHP CORS (Cross-origin resource sharing) middleware.

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

11/04 2018

v1.2.0

1.2.0.0

PHP CORS (Cross-origin resource sharing) middleware.

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

10/04 2018

v1.1.2

1.1.2.0

PHP CORS (Cross-origin resource sharing) middleware.

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

09/04 2018

v1.1.1

1.1.1.0

PHP CORS (Cross-origin resource sharing) middleware.

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

09/04 2018

v1.1.0

1.1.0.0

PHP CORS (Cross-origin resource sharing) middleware.

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

16/03 2018

v1.0.5

1.0.5.0

PHP CORS (Cross-origin resource sharing) middleware.

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

16/03 2018

v1.0.4

1.0.4.0

PHP CORS (Cross-origin resource sharing) middleware.

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

15/03 2018

v1.0.3

1.0.3.0

PHP CORS (Cross-origin resource sharing) middleware.

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

15/03 2018

v1.0.2

1.0.2.0

PHP CORS (Cross-origin resource sharing) middleware.

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

14/03 2018

v1.0.1

1.0.1.0

PHP CORS (Cross-origin resource sharing) middleware.

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires