Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9a74ab6

Browse files
committed
init
0 parents  commit 9a74ab6

16 files changed

Lines changed: 430 additions & 0 deletions

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.DS_Store
2+
.idea
3+
/vendor
4+
/build
5+
.phpunit.result.cache
6+
composer.lock

.styleci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
preset: laravel

.travis.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
language: php
2+
3+
php:
4+
- 5.6
5+
- 7.1
6+
- 7.2
7+
- 7.3
8+
9+
env:
10+
matrix:
11+
- COMPOSER_FLAGS="--prefer-lowest"
12+
- COMPOSER_FLAGS=""
13+
14+
before_script:
15+
- travis_retry composer update
16+
17+
script:
18+
- vendor/bin/phpunit

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
## [1.0.0] - 2019-03-07

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Binary Cabin
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Recaptcha
2+
3+
A laravel package for easy ReCAPTCHA integration
4+
5+
## Installation
6+
7+
```
8+
composer require binarycabin/recaptcha
9+
```
10+
11+
Publish your configuration file
12+
13+
```
14+
php artisan vendor:publish --provider="BinaryCabin\Recaptcha\Providers\RecaptchaServiceProvider" --tag="config"
15+
```
16+
17+
Update your environment variables:
18+
19+
```
20+
RECAPTCHA_VERSION=3
21+
RECAPTCHA_SITE_KEY=""
22+
RECAPTCHA_SECRET_KEY=""
23+
```
24+
25+
For local sites or test environments you can also disable recaptcha verification using:
26+
27+
```
28+
RECAPTCHA_ENABLE=false
29+
```
30+
31+
## Usage
32+
33+
At the end of your page, add the scripts needed for Google Recaptcha:
34+
35+
```
36+
{!! Recaptcha::scripts() !!}
37+
```
38+
39+
And within your form, add the hidden input that will contain your recaptcha token:
40+
41+
```
42+
{!! Recaptcha::hiddenInput() !!}
43+
```
44+
45+
Finally, add the validation in your controller:
46+
47+
```php
48+
$this->validate($request, [
49+
'recaptcha-token' => 'recaptcha',
50+
]);
51+
```
52+
53+
## Contributing
54+
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
55+
56+
Please make sure to update tests as appropriate.
57+
58+
## License
59+
[MIT](https://choosealicense.com/licenses/mit/)

composer.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "binarycabin/recaptcha",
3+
"description": "A laravel package for easy ReCAPTCHA integration",
4+
"keywords": ["laravel"],
5+
"type": "library",
6+
"license": "MIT",
7+
"authors": [
8+
{
9+
"name": "Jeff Kilroy",
10+
"email": "[email protected]"
11+
}
12+
],
13+
"require": {},
14+
"autoload":{
15+
"psr-4": {
16+
"BinaryCabin\\Recaptcha\\": "src"
17+
}
18+
},
19+
"autoload-dev":{
20+
"psr-4": {
21+
"BinaryCabin\\Recaptcha\\Tests\\": "tests"
22+
}
23+
},
24+
"extra": {
25+
"laravel": {
26+
"providers": [
27+
"BinaryCabin\\Recaptcha\\Providers\\RecaptchaServiceProvider"
28+
],
29+
"aliases": {
30+
"Recaptcha": "BinaryCabin\\Recaptcha\\Facades\\RecaptchaFacade"
31+
}
32+
}
33+
},
34+
"require-dev": {
35+
"phpunit/phpunit": ">5.0"
36+
}
37+
}

phpunit.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit backupGlobals="false"
3+
backupStaticAttributes="false"
4+
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
processIsolation="false"
10+
stopOnFailure="false"
11+
>
12+
<testsuites>
13+
<testsuite name="Package Test Suite">
14+
<directory suffix=".php">./tests/</directory>
15+
</testsuite>
16+
</testsuites>
17+
<filter>
18+
<whitelist>
19+
<directory suffix=".php">src/</directory>
20+
</whitelist>
21+
</filter>
22+
<logging>
23+
<log type="coverage-text" target="build/coverage.txt" />
24+
</logging>
25+
</phpunit>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
namespace BinaryCabin\Recaptcha\Configuration;
4+
5+
class RecaptchaConfig
6+
{
7+
private $recaptchaEnabled = true;
8+
private $recaptchaVersion = '3';
9+
private $recaptchaSiteKey = null;
10+
private $recaptchaSecretKey = null;
11+
12+
public function __construct() {
13+
$configArray = app('config')->get('recaptcha');
14+
if(isset($configArray['enable'])){
15+
$this->recaptchaEnabled = $configArray['enable'];
16+
}
17+
if(isset($configArray['version'])){
18+
$this->recaptchaVersion = $configArray['version'];
19+
}
20+
if(!empty($configArray['site_key'])){
21+
$this->recaptchaSiteKey = $configArray['site_key'];
22+
}
23+
if(!empty($configArray['secret_key'])){
24+
$this->recaptchaSecretKey = $configArray['secret_key'];
25+
}
26+
}
27+
public function getRecaptchaEnabled()
28+
{
29+
return $this->recaptchaEnabled;
30+
}
31+
32+
public function getRecaptchaVersion()
33+
{
34+
return $this->recaptchaVersion;
35+
}
36+
37+
public function getRecaptchaSiteKey()
38+
{
39+
return $this->recaptchaSiteKey;
40+
}
41+
42+
public function getRecaptchaSecretKey()
43+
{
44+
return $this->recaptchaSecretKey;
45+
}
46+
47+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
return [
4+
5+
'enable' => env('RECAPTCHA_ENABLE', true),
6+
7+
'version' => env('RECAPTCHA_VERSION', 3),
8+
9+
'site_key' => env('RECAPTCHA_SITE_KEY', null),
10+
11+
'secret_key' => env('RECAPTCHA_SECRET_KEY', null),
12+
13+
];

0 commit comments

Comments
 (0)