From 2282138280dfed438123bcb3a120c46fd1ba43f2 Mon Sep 17 00:00:00 2001 From: ARCANEDEV Date: Mon, 13 Mar 2017 16:52:28 +0000 Subject: [PATCH 1/2] Extract Laravel 5.4 Support --- .scrutinizer.yml | 4 ++-- .travis.yml | 5 +---- composer.json | 10 +++++----- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 48c2db4..282131b 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -21,8 +21,8 @@ checks: tools: external_code_coverage: - timeout: 1200 - runs: 12 + timeout: 600 + runs: 3 php_code_sniffer: enabled: true config: diff --git a/.travis.yml b/.travis.yml index cf0c625..bbe828f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,10 +13,7 @@ matrix: - php: nightly env: - - TESTBENCH_VERSION=3.0.* - - TESTBENCH_VERSION=3.1.* - - TESTBENCH_VERSION=3.2.* - - TESTBENCH_VERSION=3.3.* + - TESTBENCH_VERSION=3.4.* before_script: - travis_retry composer self-update diff --git a/composer.json b/composer.json index ba6b047..fee4704 100644 --- a/composer.json +++ b/composer.json @@ -14,11 +14,11 @@ "type": "library", "license": "MIT", "require": { - "php": ">=5.6.4", - "ext-curl": "*", - "ext-json": "*", - "arcanedev/support": "~3.20", - "psr/http-message": "~1.0" + "php": ">=5.6.4", + "ext-curl": "*", + "ext-json": "*", + "arcanedev/support": "~4.0", + "psr/http-message": "~1.0" }, "require-dev": { "arcanedev/laravel-html": "~5.0", From 6013f0a5aa6effd60c1ec95488e5b4892f0ed25c Mon Sep 17 00:00:00 2001 From: ARCANEDEV Date: Mon, 13 Mar 2017 17:08:19 +0000 Subject: [PATCH 2/2] Updating docs and random stuff --- README.md | 14 ++- _docs/0-Home.md | 12 ++- _docs/1-Installation-and-Setup.md | 90 +++++++++++++++++++ _docs/1-Requirements.md | 11 --- ...{4-Configuration.md => 2-Configuration.md} | 10 ++- _docs/2-Version-Compatibility.md | 18 ---- _docs/3-Installation-and-Setup.md | 61 ------------- _docs/{5-Usage.md => 3-Usage.md} | 11 ++- _docs/{6-Extras.md => 4-Extras.md} | 10 ++- _docs/{7-FAQ.md => 5-FAQ.md} | 10 ++- composer.json | 3 +- src/Facades/NoCaptcha.php | 6 +- src/NoCaptchaServiceProvider.php | 21 +---- tests/Laravel/ValidatorRuleTest.php | 4 +- tests/NoCaptchaServiceProviderTest.php | 1 - 15 files changed, 145 insertions(+), 137 deletions(-) create mode 100644 _docs/1-Installation-and-Setup.md delete mode 100644 _docs/1-Requirements.md rename _docs/{4-Configuration.md => 2-Configuration.md} (89%) delete mode 100644 _docs/2-Version-Compatibility.md delete mode 100644 _docs/3-Installation-and-Setup.md rename _docs/{5-Usage.md => 3-Usage.md} (93%) rename _docs/{6-Extras.md => 4-Extras.md} (92%) rename _docs/{7-FAQ.md => 5-FAQ.md} (70%) diff --git a/README.md b/README.md index 4e8a508..e0f1772 100644 --- a/README.md +++ b/README.md @@ -30,16 +30,14 @@ reCAPTCHA comes in the form of a widget that you can easily add to your blog, fo * Laravel `4.2 | 5.0 | 5.1 | 5.2 | 5.3 | 5.4` are supported. * PSR-7 Support (ServerRequest verification). * Made with :heart: & :coffee:. - + ## Table of contents - 1. [Requirements](_docs/1-Requirements.md) - 2. [Version Compatibility](_docs/2-Version-Compatibility.md) - 3. [Installation and Setup](_docs/3-Installation-and-Setup.md) - 4. [Configuration](_docs/4-Configuration.md) - 5. [Usage](_docs/5-Usage.md) - 6. [Extras](_docs/6-Extras.md) - 7. [FAQ](_docs/7-FAQ.md) + 1. [Installation and Setup](_docs/1-Installation-and-Setup.md) + 2. [Configuration](_docs/2-Configuration.md) + 3. [Usage](_docs/3-Usage.md) + 4. [Extras](_docs/4-Extras.md) + 5. [FAQ](_docs/5-FAQ.md) ## Contribution diff --git a/_docs/0-Home.md b/_docs/0-Home.md index 6a95c2c..5ef3a75 100644 --- a/_docs/0-Home.md +++ b/_docs/0-Home.md @@ -20,10 +20,8 @@ reCAPTCHA comes in the form of a widget that you can easily add to your blog, fo ## Table of contents - 1. [Requirements](1-Requirements.md) - 2. [Version Compatibility](2-Version-Compatibility.md) - 3. [Installation and Setup](3-Installation-and-Setup.md) - 4. [Configuration](4-Configuration.md) - 5. [Usage](5-Usage.md) - 6. [Extras](6-Extras.md) - 7. [FAQ](7-FAQ.md) + 1. [Installation and Setup](1-Installation-and-Setup.md) + 2. [Configuration](2-Configuration.md) + 3. [Usage](3-Usage.md) + 4. [Extras](4-Extras.md) + 5. [FAQ](5-FAQ.md) diff --git a/_docs/1-Installation-and-Setup.md b/_docs/1-Installation-and-Setup.md new file mode 100644 index 0000000..05e5b51 --- /dev/null +++ b/_docs/1-Installation-and-Setup.md @@ -0,0 +1,90 @@ +# 1. Installation + +## Table of contents + + 1. [Installation and Setup](1-Installation-and-Setup.md) + 2. [Configuration](2-Configuration.md) + 3. [Usage](3-Usage.md) + 4. [Extras](4-Extras.md) + 5. [FAQ](5-FAQ.md) + +## Requirements + + - PHP >= 5.6 + - ext-curl: * + - ext-json: * + +To use reCAPTCHA, you need to have a `site key` and a `secret key`. [Click here](https://www.google.com/recaptcha/admin) to setup a domain and get your keys. + +The `site key` is using for the widget and the `secret key` is used to validate the response we get from Google. + +For more details, check the [official documentation](https://developers.google.com/recaptcha/). + +## Version Compatibility + +| noCaptcha | Laravel | +|:----------------------------------|:--------------------------------------------------------------------------------------------------------------------| +| ![noCaptcha v1.x][no_captcha_1_x] | ![Laravel v4.2][laravel_4_2] | +| ![noCaptcha v3.x][no_captcha_3_x] | ![Laravel v5.0][laravel_5_0] ![Laravel v5.1][laravel_5_1] ![Laravel v5.2][laravel_5_2] ![Laravel v5.3][laravel_5_3] | +| ![noCaptcha v4.x][no_captcha_4_x] | ![Laravel v5.4][laravel_5_4] | + +> **Note :** This is a framework-agnostic package, so you can use any version of this package in your PHP project. + +[laravel_4_2]: https://img.shields.io/badge/v4.2-supported-brightgreen.svg?style=flat-square "Laravel v4.2" +[laravel_5_0]: https://img.shields.io/badge/v5.0-supported-brightgreen.svg?style=flat-square "Laravel v5.0" +[laravel_5_1]: https://img.shields.io/badge/v5.1-supported-brightgreen.svg?style=flat-square "Laravel v5.1" +[laravel_5_2]: https://img.shields.io/badge/v5.2-supported-brightgreen.svg?style=flat-square "Laravel v5.2" +[laravel_5_3]: https://img.shields.io/badge/v5.3-supported-brightgreen.svg?style=flat-square "Laravel v5.3" +[laravel_5_4]: https://img.shields.io/badge/v5.4-supported-brightgreen.svg?style=flat-square "Laravel v5.4" + +[no_captcha_1_x]: https://img.shields.io/badge/version-1.*-blue.svg?style=flat-square "noCaptcha v1.*" +[no_captcha_3_x]: https://img.shields.io/badge/version-3.*-blue.svg?style=flat-square "noCaptcha v3.*" +[no_captcha_4_x]: https://img.shields.io/badge/version-4.*-blue.svg?style=flat-square "noCaptcha v4.*" + +## Composer + +You can install this package via [Composer](http://getcomposer.org/) by running this command `composer require arcanedev/no-captcha`. + +> For Laravel users, please check the [Version Compatibility](2-Version-Compatibility.md) section. + +## Laravel + +### Setup + +Once the package is installed, you can register the service provider in `config/app.php` in the `providers` array: + +```php +'providers' => [ + ... + Arcanedev\NoCaptcha\NoCaptchaServiceProvider::class, +], +``` + +And the facade in the `aliases` array: + +```php +'aliases' => [ + ... + 'Captcha' => Arcanedev\NoCaptcha\Facades\NoCaptcha::class, +], +``` + +> For Laravel 4.2 (PHP 5.4), the config file is located in `app/config/app.php` + +In the `providers` array: + +```php +'providers' => [ + ... + 'Arcanedev\NoCaptcha\Laravel\ServiceProvider', +], +``` + +And the facade in the `aliases` array: + +```php +'aliases' => [ + ... + 'Captcha' => 'Arcanedev\NoCaptcha\Laravel\Facade', +], +``` diff --git a/_docs/1-Requirements.md b/_docs/1-Requirements.md deleted file mode 100644 index 199bcea..0000000 --- a/_docs/1-Requirements.md +++ /dev/null @@ -1,11 +0,0 @@ -# 1. Requirements - - - PHP >= 5.6 - - ext-curl: * - - ext-json: * - -To use reCAPTCHA, you need to have a `site key` and a `secret key`. [Click here](https://www.google.com/recaptcha/admin) to setup a domain and get your keys. - -The `site key` is using for the widget and the `secret key` is used to validate the response we get from Google. - -For more details, check the [official documentation](https://developers.google.com/recaptcha/). diff --git a/_docs/4-Configuration.md b/_docs/2-Configuration.md similarity index 89% rename from _docs/4-Configuration.md rename to _docs/2-Configuration.md index ac17143..9c9b0bd 100644 --- a/_docs/4-Configuration.md +++ b/_docs/2-Configuration.md @@ -1,4 +1,12 @@ -# 4. Configuration +# 2. Configuration + +## Table of contents + + 1. [Installation and Setup](1-Installation-and-Setup.md) + 2. [Configuration](2-Configuration.md) + 3. [Usage](3-Usage.md) + 4. [Extras](4-Extras.md) + 5. [FAQ](5-FAQ.md) There is not really a need to publish the configuration file. Both the `secret` and `sitekey` should be set in your environment file so it won't be available in your versioning system. diff --git a/_docs/2-Version-Compatibility.md b/_docs/2-Version-Compatibility.md deleted file mode 100644 index 2633f40..0000000 --- a/_docs/2-Version-Compatibility.md +++ /dev/null @@ -1,18 +0,0 @@ -# 2. Version Compatibility - -| noCaptcha | Laravel | -|:----------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------| -| ![noCaptcha v1.x][no_captcha_1_x] | ![Laravel v4.2][laravel_4_2] | -| ![noCaptcha v3.x][no_captcha_3_x] | ![Laravel v5.0][laravel_5_0] ![Laravel v5.1][laravel_5_1] ![Laravel v5.2][laravel_5_2] ![Laravel v5.3][laravel_5_3] ![Laravel v5.4][laravel_5_4] | - -> **Note :** This is a framework-agnostic package, so you can use any version of this package in your PHP project. - -[laravel_4_2]: https://img.shields.io/badge/v4.2-supported-brightgreen.svg?style=flat-square "Laravel v4.2" -[no_captcha_1_x]: https://img.shields.io/badge/version-1.*-blue.svg?style=flat-square "noCaptcha v1.*" - -[laravel_5_0]: https://img.shields.io/badge/v5.0-supported-brightgreen.svg?style=flat-square "Laravel v5.0" -[laravel_5_1]: https://img.shields.io/badge/v5.1-supported-brightgreen.svg?style=flat-square "Laravel v5.1" -[laravel_5_2]: https://img.shields.io/badge/v5.2-supported-brightgreen.svg?style=flat-square "Laravel v5.2" -[laravel_5_3]: https://img.shields.io/badge/v5.3-supported-brightgreen.svg?style=flat-square "Laravel v5.3" -[laravel_5_4]: https://img.shields.io/badge/v5.4-supported-brightgreen.svg?style=flat-square "Laravel v5.4" -[no_captcha_3_x]: https://img.shields.io/badge/version-3.*-blue.svg?style=flat-square "noCaptcha v3.*" diff --git a/_docs/3-Installation-and-Setup.md b/_docs/3-Installation-and-Setup.md deleted file mode 100644 index bf1f000..0000000 --- a/_docs/3-Installation-and-Setup.md +++ /dev/null @@ -1,61 +0,0 @@ -# 3. Installation - -## Composer - -You can install this package via [Composer](http://getcomposer.org/) by running this command `composer require arcanedev/no-captcha`. - -Or by adding the package to your `composer.json` - -```json -{ - "require": { - "arcanedev/no-captcha": "~3.0" - } -} -``` - -Then install it via `composer install` or `composer update`. - -> For Laravel users, please check the [Version Compatibility](2-Version-Compatibility.md) section. - -## Laravel - -### Setup - -Once the package is installed, you can register the service provider in `config/app.php` in the `providers` array: - -```php -'providers' => [ - ... - Arcanedev\NoCaptcha\NoCaptchaServiceProvider::class, -], -``` - -And the facade in the `aliases` array: - -```php -'aliases' => [ - ... - 'Captcha' => Arcanedev\NoCaptcha\Facades\NoCaptcha::class, -], -``` - -> For Laravel 4.2 (PHP 5.4), the config file is located in `app/config/app.php` - -In the `providers` array: - -```php -'providers' => [ - ... - 'Arcanedev\NoCaptcha\Laravel\ServiceProvider', -], -``` - -And the facade in the `aliases` array: - -```php -'aliases' => [ - ... - 'Captcha' => 'Arcanedev\NoCaptcha\Laravel\Facade', -], -``` diff --git a/_docs/5-Usage.md b/_docs/3-Usage.md similarity index 93% rename from _docs/5-Usage.md rename to _docs/3-Usage.md index 7700454..64946d0 100644 --- a/_docs/5-Usage.md +++ b/_docs/3-Usage.md @@ -1,9 +1,14 @@ -# 5. Usage +# 3. Usage ## Table of contents -* [Hard Coded (Any PHP Project)](#hard-coded-any-php-project) -* [Laravel](#laravel) + 1. [Installation and Setup](1-Installation-and-Setup.md) + 2. [Configuration](2-Configuration.md) + 3. [Usage](3-Usage.md) + * [Hard Coded (Any PHP Project)](#hard-coded-any-php-project) + * [Laravel](#laravel) + 4. [Extras](4-Extras.md) + 5. [FAQ](5-FAQ.md) ### Hard Coded (Any PHP Project) diff --git a/_docs/6-Extras.md b/_docs/4-Extras.md similarity index 92% rename from _docs/6-Extras.md rename to _docs/4-Extras.md index 9d7c2d1..e096614 100644 --- a/_docs/6-Extras.md +++ b/_docs/4-Extras.md @@ -1,4 +1,12 @@ -# 6. Extras +# 4. Extras + +## Table of contents + + 1. [Installation and Setup](1-Installation-and-Setup.md) + 2. [Configuration](2-Configuration.md) + 3. [Usage](3-Usage.md) + 4. [Extras](4-Extras.md) + 5. [FAQ](5-FAQ.md) ## g-recaptcha tag attributes diff --git a/_docs/7-FAQ.md b/_docs/5-FAQ.md similarity index 70% rename from _docs/7-FAQ.md rename to _docs/5-FAQ.md index 7090265..9c2525b 100644 --- a/_docs/7-FAQ.md +++ b/_docs/5-FAQ.md @@ -1,4 +1,12 @@ -# 7. FAQ +# 5. FAQ + +## Table of contents + + 1. [Installation and Setup](1-Installation-and-Setup.md) + 2. [Configuration](2-Configuration.md) + 3. [Usage](3-Usage.md) + 4. [Extras](4-Extras.md) + 5. [FAQ](5-FAQ.md) * **Q:** I have a question, what to do ? * **A:** Make sure to check our [GitHub issues][github_questions] for answers. diff --git a/composer.json b/composer.json index fee4704..b952c10 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,8 @@ "require-dev": { "arcanedev/laravel-html": "~5.0", "phpunit/phpcov": "~3.0", - "phpunit/phpunit": "~5.0" + "phpunit/phpunit": "~5.0", + "orchestra/testbench": "~3.0" }, "autoload": { "psr-4": { diff --git a/src/Facades/NoCaptcha.php b/src/Facades/NoCaptcha.php index ea5b2fb..0399fe9 100644 --- a/src/Facades/NoCaptcha.php +++ b/src/Facades/NoCaptcha.php @@ -1,5 +1,6 @@ registerConfig(); $this->registerNoCaptcha(); } @@ -69,7 +57,6 @@ public function provides() { return [ Contracts\NoCaptcha::class, - 'arcanedev.no-captcha', ]; } @@ -83,7 +70,7 @@ public function provides() private function registerNoCaptcha() { $this->singleton(Contracts\NoCaptcha::class, function($app) { - /** @var \Illuminate\Config\Repository $config */ + /** @var \Illuminate\Contracts\Config\Repository $config */ $config = $app['config']; return new NoCaptcha( @@ -93,8 +80,6 @@ private function registerNoCaptcha() $config->get('no-captcha.attributes', []) ); }); - - $this->singleton('arcanedev.no-captcha', Contracts\NoCaptcha::class); } /** diff --git a/tests/Laravel/ValidatorRuleTest.php b/tests/Laravel/ValidatorRuleTest.php index ee1ac84..b001e88 100644 --- a/tests/Laravel/ValidatorRuleTest.php +++ b/tests/Laravel/ValidatorRuleTest.php @@ -123,9 +123,9 @@ private function mockRequest(array $returns) $request->send(Argument::type('string')) ->willReturn($returns); - $captcha = $this->app['arcanedev.no-captcha'] + $captcha = $this->app->make(\Arcanedev\NoCaptcha\Contracts\NoCaptcha::class) ->setRequestClient($request->reveal()); - $this->app['arcanedev.no-captcha'] = $captcha; + $this->app[\Arcanedev\NoCaptcha\Contracts\NoCaptcha::class] = $captcha; } } diff --git a/tests/NoCaptchaServiceProviderTest.php b/tests/NoCaptchaServiceProviderTest.php index 35abe58..10302d3 100644 --- a/tests/NoCaptchaServiceProviderTest.php +++ b/tests/NoCaptchaServiceProviderTest.php @@ -59,7 +59,6 @@ public function it_can_provides() { $expected = [ \Arcanedev\NoCaptcha\Contracts\NoCaptcha::class, - 'arcanedev.no-captcha', ]; $this->assertEquals($expected, $this->provider->provides());