diff --git a/README.md b/README.md index 0fced29..4a6c25c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # think-captcha -thinkphp5 验证码类库 +thinkphp5.1 验证码类库 ## 安装 > composer require topthink/think-captcha diff --git a/composer.json b/composer.json index 272e516..d5350d4 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,9 @@ } ], "license": "Apache-2.0", - "require": {}, + "require": { + "topthink/framework": "5.1.*" + }, "autoload": { "psr-4": { "think\\captcha\\": "src/" diff --git a/src/Captcha.php b/src/Captcha.php index 09ad692..29f9dad 100644 --- a/src/Captcha.php +++ b/src/Captcha.php @@ -11,7 +11,7 @@ namespace think\captcha; -use think\Session; +use think\facade\Session; class Captcha { diff --git a/src/CaptchaController.php b/src/CaptchaController.php index 8a0535d..5720392 100644 --- a/src/CaptchaController.php +++ b/src/CaptchaController.php @@ -11,13 +11,13 @@ namespace think\captcha; -use think\Config; +use think\facade\Config; class CaptchaController { public function index($id = "") { - $captcha = new Captcha((array)Config::get('captcha')); + $captcha = new Captcha((array) Config::pull('captcha')); return $captcha->entry($id); } -} \ No newline at end of file +} diff --git a/src/helper.php b/src/helper.php index 914c749..7dd3cfb 100644 --- a/src/helper.php +++ b/src/helper.php @@ -9,14 +9,13 @@ // | Author: yunwuxin <448901948@qq.com> // +---------------------------------------------------------------------- -\think\Route::get('captcha/[:id]', "\\think\\captcha\\CaptchaController@index"); +Route::get('captcha/[:id]', "\\think\\captcha\\CaptchaController@index"); -\think\Validate::extend('captcha', function ($value, $id = '') { +Validate::extend('captcha', function ($value, $id = '') { return captcha_check($value, $id); }); -\think\Validate::setTypeMsg('captcha', ':attribute错误!'); - +Validate::setTypeMsg('captcha', ':attribute错误!'); /** * @param string $id @@ -29,17 +28,15 @@ function captcha($id = '', $config = []) return $captcha->entry($id); } - /** * @param $id * @return string */ function captcha_src($id = '') { - return \think\Url::build('/captcha' . ($id ? "/{$id}" : '')); + return Url::build('/captcha' . ($id ? "/{$id}" : '')); } - /** * @param $id * @return mixed @@ -49,7 +46,6 @@ function captcha_img($id = '') return 'captcha'; } - /** * @param $value * @param string $id @@ -58,6 +54,6 @@ function captcha_img($id = '') */ function captcha_check($value, $id = '') { - $captcha = new \think\captcha\Captcha((array)\think\Config::get('captcha')); + $captcha = new \think\captcha\Captcha((array) Config::pull('captcha')); return $captcha->check($value, $id); }