PHP code example of lshorz / luocaptcha

1. Go to this page and download the library: Download lshorz/luocaptcha 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/ */

    

lshorz / luocaptcha example snippets


$ composer 

Lshorz\Luosimao\LCaptchaServiceProvider::class

'LCaptcha' => Lshorz\Luosimao\Facades\LCaptcha::class,

$ php artisan vendor:publish --tag=lcaptcha

/**
* @param string $width  组件宽度
* @param string $callback 客户端验证成功回调函数名称
*/
{!! LCaptcha::render('100%', 'callback') !!}

$v = Validator::make($request->only('luotest_response'), ['luotest_response'=>'aptcha'=>'验证失败'
 ]);
if ($v->fails()) {
    return $v->errors();
} else {
    return 'ok';
}

use Lshorz\Luocaptcha\Facades\LCaptcha;

...

$res = LCaptcha::verify($request->only('luotest_response'));
if ($res) {
    echo 'passed';
} else {
    echo 'fail';
}