https://github.com/palanik/lumen-cors
CORS Middleware for Lumen micro-framework
https://github.com/palanik/lumen-cors
Last synced: 9 months ago
JSON representation
CORS Middleware for Lumen micro-framework
- Host: GitHub
- URL: https://github.com/palanik/lumen-cors
- Owner: palanik
- License: mit
- Created: 2015-04-18T02:32:35.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2018-04-09T13:01:23.000Z (about 8 years ago)
- Last Synced: 2025-05-19T15:10:01.392Z (about 1 year ago)
- Language: PHP
- Homepage:
- Size: 6.84 KB
- Stars: 101
- Watchers: 6
- Forks: 30
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-lumen - Alternative Lumen Cors - CORS Middleware for Lumen micro-framework (Packages and Middleware / Videos)
README
Lumen-CORS
==========
[Cross-origin resource sharing](https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS) (CORS) Middleware for [Lumen micro-framework](http://lumen.laravel.com/).
[](https://packagist.org/packages/palanik/lumen-cors)
[](https://github.com/palanik/lumen-cors/blob/master/LICENSE)
## Installation ##
After you install lumen as per [lumen docs](http://lumen.laravel.com/docs/installation#install-lumen), install lumen-cors from `lumen` folder.
### Install with [Composer](https://packagist.org/packages/palanik/lumen-cors) ###
Run `composer require "palanik/lumen-cors:dev-master"` to install lumen-cors.
### Manual Installation ###
Copy the file LumenCors.php into `app/Http/Middleware` directory.
## Usage ##
### 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.
```php
$app->routeMiddleware([
'cors' => 'palanik\lumen\Middleware\LumenCors',
]);
```
Then, you use the key in the route options array.
```php
$app->get('/data', ['middleware' => 'cors', function() {
//
}]);
```
More info. - http://lumen.laravel.com/docs/middleware#registering-middleware
## License ##
[MIT](LICENSE)