dev-master
9999999-dev https://github.com/aldoanizio/makorecaptchaGoogle reCaptcha Package for Mako Framework 4.0
The Requires
mail framework mako
Google reCaptcha Package for Mako Framework 4.0
Google reCaptcha Package for Mako Framework 4.0., (*1)
Use composer to install. Simply add package to your project., (*2)
composer require aldoanizio/makorecaptcha:*
So now you can update your project and install package with a single command., (*3)
composer update
After installing you'll have to register a new service in your app/config/application.php
file., (*4)
/** * Services to register in the dependecy injection container. */ 'services' => [ .... 'makorecaptcha\service\ReCaptchaService', ],
There are two ways to configure your package. The first is editing config file directly in packages folder: app/packages/makorecaptcha/config/config.php
and input the necessary information., (*5)
If you like you can copy the package's config file app/packages/makorecaptcha/config/config.php
into app/config/packages/makorecaptcha
folder and the application will load that file instead of the one located in the package. This makes it possible to update the package while keeping your custom settings., (*6)
Before use make use of captcha is needed to assign the makoReCaptcha instance to a new variable in template views., (*7)
$this->view->assign('makoReCaptcha', $this->makoReCaptcha);
To make the reCAPTCHA widget appear when your page loads, simply call the html
method in your, (*8)
<, (*9)
form> element., (*10)
To verify submited data you'll need to use the check
method parsing 3 parameters., (*11)
The first parameter is the requested address ip., (*12)
The second parameter is the auto-generated recaptcha_challenge_field
field., (*13)
The third parameter is the recaptcha_response_field
wich contains the input data., (*14)
$captcha = $this->makoReCaptcha->check($this->request->server('REMOTE_ADDR'), $this->request->post('recaptcha_challenge_field'), $this->request->post('recaptcha_response_field'));
Now you need to check if the input data is valid using the isValid
method., (*15)
if($captcha->isValid()) { // Lets Go!! } else { // Wow, hang on dude!! }
You can also use the isInvalid
method., (*16)
if($captcha->isInvalid()) { // Wow, hang on dude!! } else { // Lets Go!! }
Google reCaptcha Package for Mako Framework 4.0
mail framework mako