CaptchaService.php 533 B

1234567891011121314151617181920212223
  1. <?php
  2. namespace think\captcha;
  3. use think\Route;
  4. use think\Service;
  5. use think\Validate;
  6. class CaptchaService extends Service
  7. {
  8. public function boot()
  9. {
  10. Validate::maker(function ($validate) {
  11. $validate->extend('captcha', function ($value) {
  12. return captcha_check($value);
  13. }, ':attribute错误!');
  14. });
  15. $this->registerRoutes(function (Route $route) {
  16. $route->get('captcha/[:config]', "\\think\\captcha\\CaptchaController@index");
  17. });
  18. }
  19. }