Skip to content
This repository has been archived by the owner on Feb 23, 2023. It is now read-only.

Latest commit

 

History

History
52 lines (37 loc) · 1.19 KB

using-by-slim.md

File metadata and controls

52 lines (37 loc) · 1.19 KB

Using by Slim framework

medz/cors package supported Slim framework 3.

Configure

See 👉Configure example.

Using

Slim frameowk supported class name is Medz\Cors\Slim\Cors, Simple use:

$app = new Slim\App();
$app->add(new Medz\Cors\Slim\Cors);

💡Slim framework middleware using see https://www.slimframework.com/docs/v3/concepts/middleware.html

Using Settings

$settings = [
    // The configure see https://github.com/medz/cors#configure
];
$app = new Slim\App();
$app->add(new Medz\Cors\Slim\Cors($settings));

Using custom CORS instance

$cors = // Todo, The instance is \Medz\Cors\CorsInterface::class
$app = new Slim\App();
$app->add(new Medz\Cors\Slim\Cors($cors));

CORS middleware __construct

  • payload: This is Medz\Cors\CorsInterface or array or null
  • append: The type is boolean, If using true, All request set CORS to response hraders.

E.g:

$settings = [
    // The configure see https://github.com/medz/cors#configure
];
$appendAllResponse = true;
$app = new Slim\App();
$app->add(new Medz\Cors\Slim\Cors($settings, $appendAllResponse));