trademachines/silex-cors-provider

Service provider for Silex for addings CORS support

0.2.0 2016-06-21 05:36 UTC

This package is not auto-updated.

Last update: 2023-11-07 18:15:52 UTC


README

Build Status

Service provider for addings CORS capabilities to Silex.

Usage

There is no way of defining app-wide CORS settings, you have to do this for every single route or add necessary logic on top of the service provider.

The enable CORS support register the provider first:

$app->register(new CorsServiceProvider());

Then add CORS support per route:

$cors = new Cors();
$cors->allowOrigin('http://my.domain.com');
$app
  ->put('/posts', function() {})
  ->cors($cors);