Skip to content

Commit

Permalink
Merge pull request #22 from bocharsky-bw/patch-1
Browse files Browse the repository at this point in the history
Update docs according to the latest Symfony version
  • Loading branch information
eymengunay authored Apr 12, 2019
2 parents c7eb52b + 2a4eb52 commit 2d9082e
Showing 1 changed file with 20 additions and 33 deletions.
53 changes: 20 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,44 +19,32 @@ This version of the bundle requires Symfony 2.1+

## Installation

### Step 1: Download EoHoneypotBundle using composer
Add EoHoneypotBundle in your composer.json:
### Step 1: Download EoHoneypotBundle using Composer
Add EoHoneypotBundle to your project by running the command:
```
{
"require": {
"eo/honeypot-bundle": "dev-master"
}
}
```

Now tell composer to download the bundle by running the command:
```
$ php composer.phar update eo/honeypot-bundle
$ composer require eo/honeypot-bundle
```
Composer will install the bundle to your project's vendor/eo directory.
Composer will install the bundle to your project's `vendor/eo` directory.

### Step 2: Enable the bundle
Enable the bundle in the kernel:
If you use Symfony Flex - skip this step. Otherwise, enable the bundle in `bundles.php`:
```
<?php
// app/AppKernel.php
// config/bundles.php
public function registerBundles()
{
$bundles = array(
// ...
new Eo\HoneypotBundle\EoHoneypotBundle(),
);
}
<?php
return [
// ...
Eo\HoneypotBundle\EoHoneypotBundle::class => ['all' => true],
];
```

### Step 3 (optional): Configure bundle to use database
To save honeypot catched requests into database you have to enable it in your configuration file:
*All parameters are optional*

```
# app/config.yml
...
# config/packages/eo_honeypot.yaml
eo_honeypot:
storage:
database:
Expand Down Expand Up @@ -134,31 +122,30 @@ class HoneypotPrey extends BaseHoneypotPrey


## Usage
Once installed and configured you can start using `honeypot` type in your forms.
Once installed and configured you can start using `Eo\HoneypotBundle\Form\Type\HoneypotType`
form type in your forms.

### Basic usage example:
```
<?php
namespace Acme\DemoBundle\Form\Type;
use Eo\HoneypotBundle\Form\Type\HoneypotType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
class FooType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('name', 'text');
$builder->add('email', 'text');
$builder->add('name', TextType);
$builder->add('email', EmailType);
// Honeypot field
$builder->add('SOME-FAKE-NAME', 'honeypot');
}
public function getName()
{
return 'foo';
$builder->add('SOME-FAKE-NAME', HoneypotType::class);
}
}
```
Expand Down

0 comments on commit 2d9082e

Please sign in to comment.