CORS module for the Lumen PHP framework.
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 modify according to your needs.
For more information see the Configuration Files section in the Lumen documentation.
Available configuration options:
arrayOrigins that are allowed to perform requests, defaults to an empty array. Patterns also accepted, for example *.foo.com
arrayHTTP methods that are allowed, defaults to an empty array
arrayHTTP headers that are allowed, defaults to an empty array
booleanWhether or not the response can be exposed when credentials are present, defaults to false
arrayHTTP headers that are allowed to be exposed to the web browser, defaults to an empty array
integerIndicates how long preflight request can be cached, defaults to 0
Add the following lines to
$app->middleware([ ..... 'Nord\Lumen\Cors\CorsMiddleware', ]);
The module now automatically handles all CORS requests.
While the service can be configured somewhat using
config/cors.php, some more exotic things such as regular
expressions for allowed origins cannot. If you need to, you can provide this custom functionality yourself:
CorsServiceand override e.g.
registerBindings(), then register your own service class instead
Please read the guidelines.
Clone the project and install its dependencies by running:
Run the following command to run the test suite: