Skip to content

Commit

Permalink
laravel 8
Browse files Browse the repository at this point in the history
  • Loading branch information
desthercz committed Jan 18, 2021
1 parent dd74d80 commit 8ecdcd6
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 125 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
language: php

php:
- '7.2'
- '7.3'
- '7.4'

install:
- travis_retry composer install --no-interaction --prefer-dist --no-suggest
Expand Down
112 changes: 4 additions & 108 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
Invisible reCAPTCHA
==========
![php-badge](https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg)
[![packagist-badge](https://img.shields.io/packagist/v/albertcht/invisible-recaptcha.svg)](https://packagist.org/packages/albertcht/invisible-recaptcha)
[![Total Downloads](https://poser.pugx.org/albertcht/invisible-recaptcha/downloads)](https://packagist.org/packages/albertcht/invisible-recaptcha)
[![travis-badge](https://api.travis-ci.org/albertcht/invisible-recaptcha.svg?branch=master)](https://travis-ci.org/albertcht/invisible-recaptcha)

![invisible_recaptcha_demo](http://i.imgur.com/1dZ9XKn.png)

## Why Invisible reCAPTCHA?
Expand All @@ -19,20 +14,10 @@ In reCAPTCHA v2, users need to click the button: "I'm not a robot" to prove they
## Installation

```
composer require albertcht/invisible-recaptcha
composer require ami-praha/invisible-recaptcha
```

## Laravel 5

### Setup

Add ServiceProvider to the providers array in `app/config/app.php`.

```
AlbertCht\InvisibleReCaptcha\InvisibleReCaptchaServiceProvider::class,
```

> It also supports package discovery for Laravel 5.5.
## Laravel 8

### Configuration
Before you set your config, remember to choose `invisible reCAPTCHA` while applying for keys.
Expand Down Expand Up @@ -128,81 +113,6 @@ $validate = Validator::make(Input::all(), [

```

## CodeIgniter 3.x

set in application/config/config.php :
```php
$config['composer_autoload'] = TRUE;
```

add lines in application/config/config.php :
```php
$config['recaptcha.sitekey'] = 'sitekey';
$config['recaptcha.secret'] = 'secretkey';
// optional
$config['recaptcha.options'] = [
'hideBadge' => false,
'dataBadge' => 'bottomright',
'timeout' => 5,
'debug' => false
];
```

In controller, use:
```php
$data['captcha'] = new \AlbertCht\InvisibleReCaptcha\InvisibleReCaptcha(
$this->config->item('recaptcha.sitekey'),
$this->config->item('recaptcha.secret'),
$this->config->item('recaptcha.options'),
);
```

In view, in your form:
```php
<?php echo $captcha->render(); ?>
```

Then back in your controller you can verify it:
```php
$captcha->verifyResponse($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
```

## Without Laravel or CodeIgniter

Checkout example below:

```php
<?php

require_once "vendor/autoload.php";

$siteKey = 'sitekey';
$secretKey = 'secretkey';
// optional
$options = [
'hideBadge' => false,
'dataBadge' => 'bottomright',
'timeout' => 5,
'debug' => false
];
$captcha = new \AlbertCht\InvisibleReCaptcha\InvisibleReCaptcha($siteKey, $secretKey, $options);

// you can override single option config like this
$captcha->setOption('debug', true);

if (!empty($_POST)) {
var_dump($captcha->verifyResponse($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']));
exit();
}

?>

<form action="?" method="POST">
<?php echo $captcha->render(); ?>
<button type="submit">Submit</button>
</form>
```

## Take Control of Submit Function
Use this function only when you need to take all control after clicking submit button. Recaptcha validation will not be triggered if you return false in this function.

Expand Down Expand Up @@ -252,20 +162,6 @@ _submitEvent = function() {
};
```
## Example Repository
Repo: https://github.com/albertcht/invisible-recaptcha-example

This repo demonstrates how to use this package with ajax way.

## Showcases

* [Laravel Boilerplate](https://github.com/Labs64/laravel-boilerplate)

## Credits

* anhskohbo (the author of no-captcha package)
* [Contributors](https://github.com/albertcht/invisible-recaptcha/graphs/contributors)

## Support on Beerpay
Hey dude! Help me out for a couple of :beers:!
Repo: https://github.com/ami-praha/invisible-recaptcha-example

[![Beerpay](https://beerpay.io/albertcht/invisible-recaptcha/badge.svg?style=beer-square)](https://beerpay.io/albertcht/invisible-recaptcha) [![Beerpay](https://beerpay.io/albertcht/invisible-recaptcha/make-wish.svg?style=flat-square)](https://beerpay.io/albertcht/invisible-recaptcha?focus=wish)
This repo demonstrates how to use this package with ajax way.
22 changes: 11 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
{
"name": "albertcht/invisible-recaptcha",
"name": "ami-praha/invisible-recaptcha",
"description": "Invisible reCAPTCHA For Laravel.",
"keywords": ["recaptcha", "no-captcha", "captcha", "invisible", "invisible-recaptcha", "laravel", "laravel5", "php"],
"keywords": ["recaptcha", "no-captcha", "captcha", "invisible", "invisible-recaptcha", "laravel", "php"],
"license": "MIT",
"authors": [
{
"name": "Albert Chen",
"homepage": "https://www.albert-chen.com"
"name": "AMI Praha a.s.",
"homepage": "https://www.ami.cz"
}
],
"require": {
"php": "^5.6.4 || ^7.0",
"illuminate/support": "^5.0|^6.0|^7.0",
"guzzlehttp/guzzle": "^6.2"
"php": ">=7.3",
"illuminate/support": "^8.0",
"guzzlehttp/guzzle": "^7.0.1"
},
"require-dev": {
"phpunit/phpunit": "^8.0",
"illuminate/view": "^5.0|^6.0|^7.0"
"phpunit/phpunit": "^9.0",
"illuminate/view": "^8.0"
},
"autoload": {
"psr-4": {
"AlbertCht\\InvisibleReCaptcha\\": "src/"
"AmiPraha\\InvisibleReCaptcha\\": "src/"
}
},
"extra": {
"laravel": {
"providers": [
"AlbertCht\\InvisibleReCaptcha\\InvisibleReCaptchaServiceProvider"
"AmiPraha\\InvisibleReCaptcha\\InvisibleReCaptchaServiceProvider"
]
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Facades/InvisibleReCaptcha.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace AlbertCht\InvisibleReCaptcha\Facades;
namespace AmiPraha\InvisibleReCaptcha\Facades;

use Illuminate\Support\Facades\Facade;

Expand Down
2 changes: 1 addition & 1 deletion src/InvisibleReCaptcha.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace AlbertCht\InvisibleReCaptcha;
namespace AmiPraha\InvisibleReCaptcha;

use Symfony\Component\HttpFoundation\Request;
use GuzzleHttp\Client;
Expand Down
2 changes: 1 addition & 1 deletion src/InvisibleReCaptchaServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace AlbertCht\InvisibleReCaptcha;
namespace AmiPraha\InvisibleReCaptcha;

use Illuminate\Support\ServiceProvider;
use Illuminate\View\Compilers\BladeCompiler;
Expand Down
4 changes: 2 additions & 2 deletions tests/CaptchaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace Tests;

use AlbertCht\InvisibleReCaptcha\InvisibleReCaptchaServiceProvider;
use AmiPraha\InvisibleReCaptcha\InvisibleReCaptchaServiceProvider;
use Illuminate\Container\Container;
use Illuminate\Filesystem\Filesystem;
use Illuminate\View\Compilers\BladeCompiler;
use PHPUnit\Framework\TestCase;
use AlbertCht\InvisibleReCaptcha\InvisibleReCaptcha;
use AmiPraha\InvisibleReCaptcha\InvisibleReCaptcha;

class CaptchaTest extends TestCase
{
Expand Down

0 comments on commit 8ecdcd6

Please sign in to comment.