php composer 安装组件 captcha 验证码使用

* 搜索catcha相关的包

https://packagist.org/

输入captcha

var search = document.getElementById("search_query_query")
search.value = "captcha"
document.forms.search_query.submit()

* 命令行安装 组件

composer require gregwar/captcha

如果没有composer命令  

安装composer: https://blog.csdn.net/fareast_mzh/article/details/81463824

 https://packagist.org/packages/gregwar/captcha

自动生成composer.json

{
    "require": {
        "gregwar/captcha": "^1.1"
    }
}

* 创建index.php

build();

setcookie('phrase', $builder->getPhrase());

header('Content-type: image/jpeg');
$builder->output();

* 运行

php -S 0.0.0.0:9000

浏览器访问http://localhost:9000/

打开控制台 查看cookie

document.cookie

php composer 安装组件 captcha 验证码使用_第1张图片

你可能感兴趣的:(web,php)