2017 © Pedro Peláez
 

library silex-cors-provider

A silex service provider that adds CORS services to silex

image

jdesrosiers/silex-cors-provider

A silex service provider that adds CORS services to silex

  • Sunday, March 25, 2018
  • by jdesrosiers
  • Repository
  • 9 Watchers
  • 79 Stars
  • 335,463 Installations
  • PHP
  • 14 Dependents
  • 0 Suggesters
  • 24 Forks
  • 1 Open issues
  • 26 Versions
  • 7 % Grown

The README.md

silex-cors-provider

Build Status Scrutinizer Code Quality Code Coverage, (*1)

The CorsServiceProvider provides CORS support as middleware for your silex application. CORS allows you to make AJAX requests across domains. CORS uses OPTIONS requests to make preflight requests. Because silex doesn't have functionality for serving OPTIONS request by default, this service goes through all of your routes and generates the necessary OPTIONS routes., (*2)

Installation

Install the silex-cors-provider using composer. This project uses sematic versioning., (*3)

composer require jdesrosiers/silex-cors-provider "~1.0"

Parameters

  • cors.allowOrigin: (string) Space separated set of allowed domains (wildcards allowed e.g. http://*.example.com). Defaults to all.
  • cors.allowMethods: (string) Comma separated set of allowed HTTP methods. Defaults to all.
  • cors.allowHeaders: (string) Comma separated set of allowed HTTP request headers. Defaults to all.
  • cors.maxAge: (int) The number of seconds a CORS pre-flight response can be cached. Defaults to 0.
  • cors.allowCredentials: (boolean) Are cookies allowed? Defaults to false.
  • cors.exposeHeaders: (string) Comma separated set of headers that are safe to expose. Defaults to none. This should not include the six simple response headers which are always exposed: Cache-Control, Content-Language, Content-Type, Expires, Last-Modified, Pragma.

Services

  • cors: A function that can be added as after middleware to the Application. (Deprecated. Use cors-enabled instead)
  • cors-enabled: Pass this function an Application, a ControllerCollection, or a Controller and it will enable CORS support for every route the object defines. Optionally, you can pass an array of options as a second parameter. The options you can pass are the same as the cors.* parameters without the cors. part. This is useful of you need different configuration for different routes.
  • options: Similar to cors-enabled but only creates OPTIONS routes with no CORS support.
  • allow: A function that can be added as after middleware to an Application, a ControllerCollection, or a Controller that will add an Allow header to every route the object defines.

Registering

$app->register(new JDesrosiers\Silex\Provider\CorsServiceProvider(), [
    "cors.allowOrigin" => "http://petstore.swagger.wordnik.com",
]);

Usage

Add CORS functionality to the entire application., (*4)

$app->get("/foo/{id}", function ($id) { /* ... */ });
$app->post("/foo/", function () { /* ... */ });

$app["cors-enabled"]($app);

Add CORS functionality to a controller collection., (*5)

$foo = $app["controllers_factory"];
$foo->get("/{id}", function () { /* ... */ });
$foo->post("/", function () { /* ... */ });
$app->mount("/foo", $app["cors-enabled"]($foo));

$app->get("/bar/{id}", function ($id) { /* ... */ }); // Not CORS enabled

Add CORS functionality to a controller., (*6)

$controller = $app->get("/foo/{id}", function ($id) { /* ... */ });
$app["cors-enabled"]($controller);
$app->post("/foo/", function () { /* ... */ }); // Not CORS enabled

The Versions

25/03 2018

dev-master

9999999-dev

A silex service provider that adds CORS services to silex

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jason Desrosiers

service cors silex resource provider sharing cross origin

25/03 2018

v1.6.0

1.6.0.0

A silex service provider that adds CORS services to silex

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jason Desrosiers

service cors silex resource provider sharing cross origin

20/10 2017

v0.x-dev

0.9999999.9999999.9999999-dev

A silex service provider that adds CORS services to silex

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jason Desrosiers

service cors silex resource provider sharing cross origin

20/10 2017

v0.6.0

0.6.0.0

A silex service provider that adds CORS services to silex

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jason Desrosiers

service cors silex resource provider sharing cross origin

20/10 2017

v1.5.0

1.5.0.0

A silex service provider that adds CORS services to silex

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jason Desrosiers

service cors silex resource provider sharing cross origin

20/09 2017

v0.5.2

0.5.2.0

A silex service provider that adds CORS services to silex

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jason Desrosiers

service cors silex resource provider sharing cross origin

20/09 2017

v1.4.2

1.4.2.0

A silex service provider that adds CORS services to silex

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jason Desrosiers

service cors silex resource provider sharing cross origin

21/07 2017

v0.5.1

0.5.1.0

A silex service provider that adds CORS services to silex

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jason Desrosiers

service cors silex resource provider sharing cross origin

21/07 2017

v1.4.1

1.4.1.0

A silex service provider that adds CORS services to silex

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jason Desrosiers

service cors silex resource provider sharing cross origin

10/03 2017

v0.5.0

0.5.0.0

A silex service provider that adds CORS services to silex

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jason Desrosiers

service cors silex resource provider sharing cross origin

10/03 2017

v1.4.0

1.4.0.0

A silex service provider that adds CORS services to silex

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jason Desrosiers

service cors silex resource provider sharing cross origin

09/03 2017

v0.4.0

0.4.0.0

A silex service provider that adds CORS services to silex

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jason Desrosiers

service cors silex resource provider sharing cross origin

09/03 2017

v1.3.0

1.3.0.0

A silex service provider that adds CORS services to silex

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jason Desrosiers

service cors silex resource provider sharing cross origin

08/03 2017

v0.3.1

0.3.1.0

A silex service provider that adds CORS services to silex

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jason Desrosiers

service cors silex resource provider sharing cross origin

08/03 2017

v1.2.1

1.2.1.0

A silex service provider that adds CORS services to silex

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jason Desrosiers

service cors silex resource provider sharing cross origin

17/02 2017

v0.3.0

0.3.0.0

A silex service provider that adds CORS services to silex

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jason Desrosiers

service cors silex resource provider sharing cross origin

17/02 2017

v1.2.0

1.2.0.0

A silex service provider that adds CORS services to silex

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jason Desrosiers

service cors silex resource provider sharing cross origin

16/02 2017

v0.2.0

0.2.0.0

A silex service provider that adds CORS services to silex

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jason Desrosiers

service cors silex resource provider sharing cross origin

16/02 2017

v1.1.0

1.1.0.0

A silex service provider that adds CORS services to silex

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jason Desrosiers

service cors silex resource provider sharing cross origin

05/06 2016

v1.0.0

1.0.0.0

A silex service provider that adds CORS services to silex

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jason Desrosiers

service cors silex resource provider sharing cross origin

13/09 2015

v0.1.5

0.1.5.0

A silex service provider that adds CORS services to silex

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jason Desrosiers

service cors silex resource provider sharing cross origin

11/06 2015

v0.1.4

0.1.4.0

A silex service provider that adds CORS services to silex

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jason Desrosiers

service cors silex resource provider sharing cross origin

08/08 2014

v0.1.3

0.1.3.0

A silex service provider that adds CORS services to silex

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jason Desrosiers

service cors silex resource provider sharing cross origin

12/11 2013

v0.1.2

0.1.2.0

A silex service provider that adds CORS services to silex

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jason Desrosiers

service cors silex resource provider sharing cross origin

26/10 2013

v0.1.1

0.1.1.0

A silex service provider that adds CORS services to silex

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jason Desrosiers

service cors silex resource provider sharing cross origin

03/10 2013

v0.1.0

0.1.0.0

A silex service provider that adds CORS services to silex

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jason Desrosiers

service cors silex resource provider sharing cross origin