Skip to content

Commit

Permalink
license, CI and badges
Browse files Browse the repository at this point in the history
  • Loading branch information
Erwane committed Aug 17, 2022
1 parent 171b3c6 commit 44c6f43
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
codecov:
require_ci_to_pass: yes

coverage:
range: "90...100"

comment: false
57 changes: 57 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: CI

on:
push:
branches:
- 1.x
pull_request:
branches:
- '*'

jobs:
testsuite:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version: ['7.2', '8.0', '8.1']

steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl, apcu, pdo_${{ matrix.db-type }}
ini-values: apc.enable_cli = 1
coverage: pcov

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Get date part for cache key
id: key-date
run: echo "::set-output name=date::$(date +'%Y-%m')"

- name: Cache composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }}

- name: Composer install
run: |
composer update
- name: Run PHPUnit
run: |
if [[ ${{ matrix.php-version }} == '8.1' ]]; then
export CODECOVERAGE=1 && vendor/bin/phpunit --verbose --coverage-clover=coverage.xml
else
vendor/bin/phpunit
fi
- name: Submit code coverage
if: matrix.php-version == '8.1'
uses: codecov/codecov-action@v3
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (C) Erwane Breton. (https://erwane-breton.fr/)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
31 changes: 29 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
# HCaptcha plugin for CakePHP 4.x

![Build Status](https://github.com/Erwane/cakephp-hcaptcha/actions/workflows/ci.yml/badge.svg?branch=1.x)
[![codecov](https://codecov.io/gh/Erwane/cakephp-hcaptcha/branch/1.x/graph/badge.svg?token=NNY4FBXCEE)](https://codecov.io/gh/Erwane/cakephp-hcaptcha)
[![Total Downloads](https://img.shields.io/packagist/dt/Erwane/cakephp-hcaptcha?style=flat-square)](https://packagist.org/packages/Erwane/cakephp-hcaptcha/stats)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.txt)

## Installation

With composer

```
composer require erwane/cakephp-hcaptcha
```

Load plugin in your `src/Application::bootstrap()`

```php
public function bootstrap(): void
{
Expand All @@ -16,6 +23,7 @@ Load plugin in your `src/Application::bootstrap()`
```

## Configuration

In your `config/app.php`, insert this default values:

```php
Expand All @@ -35,11 +43,30 @@ In your `config/app.php`, insert this default values:
HCaptcha key and secret can be found in your [HCaptcha dashboard](https://dashboard.hcaptcha.com/sites?page=1)

## Usage

### In your templates

Add the captcha to your form
```html

```php
<?= $this->Form->control('h-captcha-response', ['type' => 'hcaptcha']) ?>
```
In your form validation, could be a model or modelless form, add Validation provider and use `hcaptcha` rule

You can pass options to hCaptcha.

```php
<?= $this->Form->control('h-captcha-response', [
'type' => 'hcaptcha',
'lang' => 'fr_FR',
'onload' => 'myFunction',
'render' => 'explicit',
'recaptchacompat' => false,
]) ?>
```

### Validation

In your `Model` or `Form` validation, add hCaptcha validation provider and define your rule.

```php
use Cake\Validation\Validator;
Expand Down

0 comments on commit 44c6f43

Please sign in to comment.