From 1bb2a729b7cb551f131e4fa02a81604d60394c05 Mon Sep 17 00:00:00 2001 From: "17705211605@163.com" <17705211605@163.com> Date: Tue, 8 Aug 2017 23:03:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E9=94=99=E8=AF=AF=EF=BC=8C=E6=B7=BB=E5=8A=A0=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 27 +++++++++++++++++++++++++++ composer.json | 2 +- src/command/SendConfig.php | 2 +- src/config.php | 2 +- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cd75a43..f93bbdd 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,29 @@ # aycors thinkphp5 for cors + +## 安装方法 + +### 第一步 使用composer下载SDK + +```bash +composer require ayteam/aycors +``` + +### 第二步 项目根目录执行 + +```bash +php think cors:config +``` + +> 查看application/extra/cors.php这个文件是否存在, +如果不存在复制一份 [config.php](https://github.com/ayteam/aycors/blob/master/src/config.php) +到 application/extra + +## 使用方法 +具体参考 [跨域资源共享 CORS 详解](http://www.ruanyifeng.com/blog/2016/04/cors.html) + +```php +return Cors::json(['code'=>1]); +``` +如果有不懂的,可以下面评论。 +也欢迎大家在github提交issue和PR diff --git a/composer.json b/composer.json index 9e4ec5e..5a67065 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "keywords": [ "thinkphp5", "cors", - "Access-Control-Allow-Origin" + "Cross-origin resource sharing" ], "license": "MIT", "authors": [ diff --git a/src/command/SendConfig.php b/src/command/SendConfig.php index 2a14461..c3b3d79 100644 --- a/src/command/SendConfig.php +++ b/src/command/SendConfig.php @@ -21,7 +21,7 @@ public function configure() public function execute(Input $input, Output $output) { //获取默认配置文件 - $content = file_get_contents(VENDOR_PATH .'aycors/tp-cors/src/config.php'); + $content = file_get_contents(VENDOR_PATH .'ayteam/aycors/src/config.php'); $configPath = CONF_PATH.'extra/'; $configFile = $configPath.'cors.php'; //判断目录是否存在 diff --git a/src/config.php b/src/config.php index 2022879..a845d7c 100644 --- a/src/config.php +++ b/src/config.php @@ -16,7 +16,7 @@ | to accept any value. | */ - 'supportsCredentials' => false, + 'supportsCredentials' => true, 'allowedOrigins' => ['*'], 'allowedHeaders' => ['*'], 'allowedMethods' => ['*'],