muyu / no-captcha
A completely useless verification code
1.1.1
2017-01-18 14:46 UTC
Requires
- php: >=5.5.9
- doctrine/cache: ^1.6
Requires (Dev)
- phpunit/phpunit: ~4.0
- predis/predis: ^1.1
- symfony/var-dumper: ^3.2
This package is not auto-updated.
Last update: 2024-05-11 18:18:18 UTC
README
Building...
How to render page ?
public function getCode()
{
$ctl = new Template();
return $ctl->view('code', [
'generate' => 'http://127.0.0.1/auth/code-generate',
'valid' => 'http://127.0.0.1/auth/code-valid',
'query' => 'http://127.0.0.1/auth/code-query',
'name' => 'Muyu',
'sign' => 'Inc',
'message' => '吾,非机器人也',
]);
}
How to use ?
private $captcha;
public function __construct()
{
$this->captcha = new Captcha();
/**
* you can choose
* useFile | useRedis | useMemcache
* param is driver connection instance
*/
$this->captcha->useMemcache($memcached);
}
public function postLogin()
{
if(! $this->getCodeQuery())
{
throw new Exception('you are robot');
}
}
public function getCodeGenerate()
{
return $this->captcha->generate();
}
public function getCodeValid()
{
return $this->captcha->valid();
}
private function getCodeQuery()
{
return $this->captcha->query();
}