haohetao/yii2-rest-api-captcha

The captcha image generator for restful api

2.1.4 2018-09-11 03:49 UTC

This package is auto-updated.

Last update: 2024-11-09 16:42:55 UTC


README

Simple captcha image generator for restful api 22

Installation

Recommended installation via composer:

composer require haohetao/yii2-rest-api-captcha

Usage

Generate captcha code (image/png;base64):

    public function actions()
    {
        return [
            'captcha' => [
                'class' => 'haohetao\captcha\CaptchaAction',
                'maxLength' => 4,
                'minLength' => 4
            ]
        ];
    }

use in curl(for test):

curl http://localhost/site/captcha

Verify captcha code:

    public function rules()
    {
        return [
            [
                'code', \haohetao\captcha\CaptchaValidator::class
            ]
        ];
    }