定制 nordsoftware/lumen-cors 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nordsoftware/lumen-cors

最新稳定版本:3.5.0

Composer 安装命令:

composer require nordsoftware/lumen-cors

包简介

CORS module for the Lumen PHP framework.

README 文档

README

GitHub Actions status Coverage Status Code Climate Scrutinizer Code Quality StyleCI Latest Stable Version Total Downloads License

Cross-Origin Resource Sharing (CORS) module for the Lumen PHP framework.

Requirements

Usage

Installation

Run the following command to install the package through Composer:

composer require nordsoftware/lumen-cors

Configure

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:

  • allow_origins array Origins that are allowed to perform requests, defaults to an empty array. Patterns also accepted, for example *.foo.com
  • allow_methods array HTTP methods that are allowed, defaults to an empty array
  • allow_headers array HTTP headers that are allowed, defaults to an empty array
  • allow_credentials boolean Whether or not the response can be exposed when credentials are present, defaults to false
  • expose_headers array HTTP headers that are allowed to be exposed to the web browser, defaults to an empty array
  • max_age integer Indicates how long preflight request can be cached, defaults to 0

Bootstrapping

Add the following lines to bootstrap/app.php:

$app->register('Nord\Lumen\Cors\CorsServiceProvider');
$app->middleware([
	.....
	'Nord\Lumen\Cors\CorsMiddleware',
]);

The module now automatically handles all CORS requests.

Customizing behavior

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:

  1. Extend CorsService and override e.g. isOriginAllowed()
  2. Extend CorsServiceProvider and override registerBindings(), then register your own service class instead

Contributing

Please read the guidelines.

Running tests

Clone the project and install its dependencies by running:

composer install

Run the following command to run the test suite:

composer test

License

See LICENSE.

统计信息

  • 总下载量: 495.11k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 100
  • 点击次数: 2
  • 依赖项目数: 3
  • 推荐数: 1

GitHub 信息

  • Stars: 98
  • Watchers: 15
  • Forks: 35
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-05-14