承接 denismitr/laracors 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

denismitr/laracors

Composer 安装命令:

composer require denismitr/laracors

包简介

Cross Origin Resource Sharing Middleware for Laravel or Lumen

README 文档

README

Laravel Cross Origin Resource Sharing Middleware

This middleware is designed specifically for the Laravel and Lumen frameworks and the RESTful APIs builded with them. It allows requests to made from JS frontends of other apps.

Author

Denis Mitrofanov

TheCollection.ru

Installation

Use composer to install the package:

composer require denismitr/laracors

Laravel

Add to config/app.php:

'providers' => [
    ...
    \Denismitr\Laracors\LaravelCorsServiceProvider::class,
],

Include in your app/Http/Kernel.php to the appropriate section (all requests if all your routes are API or named middleware + API middleware group to make it work for every api route or just named middleware):

Global middleware

protected $middleware = [
    ...
    \Denismitr\Laracors\Cors::class
];

Publish the config file:

php artisan vendor:publish  --provider="Denismitr\Laracors\LaravelCorsServiceProvider"

Edit the config/laracors.php file to your needs.

Named middleware
---------------
```php

protected $routeMiddleware = [
    ...
    'cors' => \Denismitr\Laracors\LaravelCorsServiceProvider::class,
];

protected $middlewareGroups = [
    'web' => [
        ...
    ],

    'api' => [
        ...
        'cors'
    ],
];

Middleware parameters

Route::put('post/{id}', function ($id) {
    //
})->middleware('cors:get,post,put');

Lumen

Add the following lines to bootstrap/app.php:

$app->register('\Denismitr\Laracors\LumenCorsServiceProvider');
$app->middleware([
    .....
    '\Denismitr\Laracors\Cors',
]);

统计信息

  • 总下载量: 113
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-06-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固