美文网首页我爱编程
使用 Captcha 扩展包 为 Laravel 5 应用生成验

使用 Captcha 扩展包 为 Laravel 5 应用生成验

作者: hansel666 | 来源:发表于2018-04-07 20:37 被阅读0次

Laravel框架并没有集成验证码类库,我们使用大神写好的captcha扩展包来帮助我们实现该功能

1、安装

我们通过 Composer 安装 Captcha 扩展包:

composer require mews/captcha

composer全局配置

composer config -g repo.packagist composer https://packagist.phpcomposer.com

php版本要求7.1以上,我们使用官方提供的homestead都可以引用成功

2、配置

使用Captcha服务提供者之前还需要在config/app.php中注册服务提供者:

'providers' => [

    // ...

 Mews\Captcha\CaptchaServiceProvider::class,

]

同时注册下相应门面:

'aliases' => [

    // ...

    'Captcha' => Mews\Captcha\Facades\Captcha::class,

]

如果要使用自定义的配置,还可以发布配置文件到config目录:

$ php artisan vendor:publish

编辑新生成的captcha.php:

return [

    'default' => [

        'length' => 5,

        'width' => 120,

        'height' => 36,

        'quality' => 90,

    ],

    // ...

];

3、使用示例

显示验证码:captcha_src()直接使用就可以了

验证 验证码 captcha_check($code) 返回布尔值。很是方便

相关文章

网友评论

    本文标题:使用 Captcha 扩展包 为 Laravel 5 应用生成验

    本文链接:https://www.haomeiwen.com/subject/nffuhftx.html