Cross-Origin Resource Sharing (CORS) module for the Lumen PHP framework.
- PHP 5.4 or newer
- Composer
Run the following command to install the package through Composer:
composer require nordsoftware/lumen-cors
Copy the configuration template in config/cors.php
to your application's config
directory and modifying according to your needs.
For more information see the Configuration Files section in the Lumen documentation.
Available configuration options:
- allowOrigins - Origins that are allowed to perform requests, defaults to an empty array
- allowHeaders - HTTP headers that are allowed, defaults to an empty array
- allowMethods - HTTP methods that are allowed, defaults to an empty array
- allowCredentials - Whether or not the response can be exposed when credentials are present, defaults to false
- exposeHeaders - HTTP Headers that are allowed to be exposed to the web browser, defaults to an empty array
- maxAge - Indicates how long preflight request can be cached, defaults to 0
Add the following lines to bootstrap/app.php
:
$app->configure('cors');
$app->register('Nord\Lumen\Cors\CorsServiceProvider');
$app->middleware([
.....
'Nord\Lumen\Cors\Middleware\CorsMiddleware',
]);
The module now automatically handles all CORS requests.
Please note the following guidelines before submitting pull requests:
- Use the PSR-2 coding style
- All new features must be covered by unit tests
- Always create pull requests to the develop branch
Clone the project and install its dependencies by running:
composer install
Run the following command to run the test suite:
vendor/bin/codecept run unit
See LICENSE.