PHP code example of softark / yii2-mb-captcha

1. Go to this page and download the library: Download softark/yii2-mb-captcha library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

softark / yii2-mb-captcha example snippets


    "    "php": ">=5.4.0",
        "yiisoft/yii2": "~2.0.44",
        "yiisoft/yii2-bootstrap": "*",
        "yiisoft/yii2-swiftmailer": "*",
        "softark/yii2-mb-captcha": "dev-master"
    },
    

    /* use yii\captcha\Captcha; */
    use softark\mbcaptcha\Captcha;
    ...
    <?=
        $form->field($model, 'verifyCode')->widget(Captcha::className(), [
            'template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>',
        ]) 

    /* use yii\captcha\Captcha; */
    use softark\mbcaptcha\Captcha;
    <?=
        $form->field($model, 'verifyCode')->widget(Captcha::className(), [
            'template' => '<div class="row"><div class="col-lg-3">{image} {link}</div><div class="col-lg-6">{input}</div></div>',
        ]) 

    public function actions()
    {
        return [
            'captcha' => [
                /* 'class' => 'yii\captcha\CaptchaAction', */
                'class' => 'softark\mbcaptcha\CaptchaAction',
                'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
            ],
            ...
        ];
    }
    

use softark\mbcaptcha\Captcha;
...
<?=
    $form->field($model, 'verifyCode')->widget(Captcha::className(), [
        'template' => '<div class="row"><div class="col-lg-3">{image} {link}</div><div class="col-lg-6">{input}</div></div>',
        'toggleLinkLabel' => '漢字/abc',
    ]) 

public function actions()
{
    return [
        'captcha' => [
            'class' => 'softark\mbcaptcha\CaptchaAction',
            'seeds' => '几乎所有的应用程序都是建立在数据库之上虽然可以非常灵活的' .
                '操作数据库但有些时候一些设计的选择可以使它更便于使用首先应用程序' .
                '广泛使用了设计的考虑主要围绕优化使用而不是组成复杂语句实际上大多' .
                '的设计是使用友好的模式来解决实践中的问题最常用的方式是创建易于被' .
                '人阅读和理解的代码例如使用命名来传达意思但是这很难做到',
            'mbFontFile' => '@frontend/fonts/gbsn00lp.ttf',
        ],
        ...
    ];
}