The CorsServiceProvider provides CORS support as middleware for your silex 2.0 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.
Add euskadi31/cors-service-provider
to your composer.json
:
% php composer.phar require euskadi31/cors-service-provider:~1.0
<?php
$app = new Silex\Application;
$app->register(new \Euskadi31\Silex\Provider\CorsServiceProvider);
CorsServiceProvider is licensed under the MIT license.