Tag Archives: PHP

Using reCaptcha v2 (No Captcha) on Laravel

Google has launched the new way to verify that your web visitors are not robots. As we know, it’s known as reCaptcha, but on the latest version it’s called No Captcha. Why? Because you don’t have to type anything but only a click on a check box.

Now, I want to show you how to add this captcha to a web application using Laravel framework.

To be straightforward, add this line to your composer.json in section “require”

        "greggilbert/recaptcha": "dev-master"

then run this command

php composer.json update

Next, Add Greggilbert\Recaptcha\RecaptchaServiceProvider to the service provider list in app/config/app.php

Run php artisan config:publish greggilbert/recaptcha

In app/config/packages/greggilbert/recaptcha/config.php, enter your reCAPTCHA public and private keys. You should create a new key pair in order to use No Captcha. (fill the public key with site key).


Add the following line into app/lang/[lang]/validation.php

"recaptcha" => 'The :attribute field is not correct.',

Open vendor/zizaco/confide/src/views/signup.blade.php

then add this line just after password confirmation div closing tag

{{ Form::captcha() }}

For validation, add these code to app/controllers/user/UserController.php

$rules = array(
 'g-recaptcha-response' => 'required|recaptcha',
 $validator = Validator::make(Input::all(),$rules);
// process the login
 if ($validator->fails()) {
 return Redirect::to('user/create')

Now, time for testing. Open your sign-up page and you will see the new look reCaptcha.




PHP Warning: ‘It is not safe to rely on the system’s timezone settings’ when using date() function

If you get this error on your PHP baseb web application, this means you haven’t set your timezone in your PHP environment. So the date() function will use time information from your OS timezone.

To prevent this error, just open your php.ini file, change the parameter:

; date.timezone

to (depends on your location, for example Jakarta):

date.timezone = 'Asia/Jakarta'

Save, and restart your web server daemon.

%d bloggers like this: