protobia-alpha / geetest
Laravel 极验验证封装
This package's canonical repository appears to be gone and the package has been frozen as a result.
1.0.3
2017-04-12 14:49 UTC
This package is not auto-updated.
Last update: 2021-03-20 08:52:49 UTC
README
Installation
The preferred method of installation is via Packagist and Composer. Run the following command to install the package and add it as a requirement to your project's composer.json
:
composer require protobia-alpha/geetest
config/app.php
... 'providers' => [ ... ProtobiaAlpha\Geetest\GeetestServiceProvider::class, ] ... 'alias' => [ ... 'Geetest' => ProtobiaAlpha\Geetest\GeetestFacade::class, ]
Configuration
php artisan vendor:publish
Usage
.env
... GEETEST_ID= GEETEST_KEY=
x.blade.php
... {!! Geetest::render() !!} {!! Geetest::render('embed') !!} {!! Geetest::render('popup') !!} ...
Example
ExampleController.php
use Illuminate\Http\Request; class ExampleController extends Controller { /** * @param Request $request */ public function postValidate(Request $request) { $this->validate($request, [ 'geetest_challenge' => 'geetest', ], [ 'geetest' => config('geetest.server_fail_alert'), ]); dd(true); } /** * @param Request $request */ public function postValidateOther(Request $request) { dd(\Geetest::validate($request)); } }
example.blade.php
<html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>极验测试</title> </head> <body> <form action="/gee/test" method="post"> <input name="_token" type="hidden" value="{{ csrf_token() }}"> <input type="submit" value="submit"> {!! Geetest::render() !!} </form> </body> </html>