Cross-origin resource sharing (CORS) middleware for Lumen micro-framework.

v0.0.3 2017-06-24 03:53 UTC

This package is auto-updated.

Last update: 2023-05-24 10:22:00 UTC


Cross-origin resource sharing (CORS) Middleware for Lumen micro-framework.

Latest Stable Version License


After you install lumen as per lumen docs, install lumen-cors from lumen folder.

Install with Composer

Run composer require "palanik/lumen-cors:dev-master" to install lumen-cors.

Manual Installation

Copy the file LumenCors.php into app/Http/Middleware directory.


Global CORS

If you want CORS enabled for every HTTP request to your application, simply list the middleware class palanik\lumen\Middleware\LumenCors in the $app->middleware() call of your bootstrap/app.php file.

CORS for Routes

If you would like to enable CORS to specific routes, you should first assign the lumen-cors middleware a short-hand key in your bootstrap/app.php file.

    'cors' => 'palanik\lumen\Middleware\LumenCors',

Then, you use the key in the route options array.

$app->get('/data', ['middleware' => 'cors', function() {

More info. -