Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
df6915eb5e | |||
b7685e63a1 | |||
15bee25e9c | |||
3a4e31473a | |||
fec0ebb2f1 |
31
README.md
31
README.md
@ -45,7 +45,7 @@ Configuration
|
|||||||
|
|
||||||
If you need to customize the global bundle configuration, you can create a `/config/packages/gregwar_captcha.yaml` file with your configuration:
|
If you need to customize the global bundle configuration, you can create a `/config/packages/gregwar_captcha.yaml` file with your configuration:
|
||||||
``` yaml
|
``` yaml
|
||||||
gregwar_captcha:
|
gregwar_captcha:
|
||||||
width: 160
|
width: 160
|
||||||
height: 50
|
height: 50
|
||||||
```
|
```
|
||||||
@ -57,10 +57,10 @@ You can use the "captcha" type in your forms this way:
|
|||||||
|
|
||||||
``` php
|
``` php
|
||||||
<?php
|
<?php
|
||||||
use Gregwar\CaptchaBundle\Type\CaptchaType;
|
use Gregwar\CaptchaBundle\Type\CaptchaType;
|
||||||
// ...
|
// ...
|
||||||
$builder->add('captcha', CaptchaType::class); // That's all !
|
$builder->add('captcha', CaptchaType::class); // That's all !
|
||||||
// ...
|
// ...
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that the generated image will, by default, be embedded in the HTML document
|
Note that the generated image will, by default, be embedded in the HTML document
|
||||||
@ -101,24 +101,25 @@ number of lines depends on the size of the image). (default=null)
|
|||||||
* **background_images**: Sets custom user defined images as the captcha background (1 image is selected randomly). It is recommended to turn off all the effects on the image (ignore_all_effects). The full paths to the images must be passed.
|
* **background_images**: Sets custom user defined images as the captcha background (1 image is selected randomly). It is recommended to turn off all the effects on the image (ignore_all_effects). The full paths to the images must be passed.
|
||||||
* **interpolation**: enable or disable the interpolation on the captcha
|
* **interpolation**: enable or disable the interpolation on the captcha
|
||||||
* **ignore_all_effects**: Recommended to use when setting background images, will disable all image effects.
|
* **ignore_all_effects**: Recommended to use when setting background images, will disable all image effects.
|
||||||
|
* **session_key**, if you want to host multiple CAPTCHA on the same page, you might have different session keys to ensure proper storage of the clear phrase for those different forms
|
||||||
|
|
||||||
Example :
|
Example :
|
||||||
|
|
||||||
``` php
|
``` php
|
||||||
<?php
|
<?php
|
||||||
use Gregwar\CaptchaBundle\Type\CaptchaType;
|
use Gregwar\CaptchaBundle\Type\CaptchaType;
|
||||||
// ...
|
// ...
|
||||||
$builder->add('captcha', CaptchaType::class, array(
|
$builder->add('captcha', CaptchaType::class, array(
|
||||||
'width' => 200,
|
'width' => 200,
|
||||||
'height' => 50,
|
'height' => 50,
|
||||||
'length' => 6,
|
'length' => 6,
|
||||||
));
|
));
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also set these options for your whole application using the `gregwar_captcha`
|
You can also set these options for your whole application using the `gregwar_captcha`
|
||||||
configuration entry in your `config.yml` file:
|
configuration entry in your `config.yml` file:
|
||||||
``` yaml
|
``` yaml
|
||||||
gregwar_captcha:
|
gregwar_captcha:
|
||||||
width: 200
|
width: 200
|
||||||
height: 50
|
height: 50
|
||||||
length: 6
|
length: 6
|
||||||
@ -131,15 +132,17 @@ The messages are using the translator, you can either change the `invalid_messag
|
|||||||
|
|
||||||
As URL
|
As URL
|
||||||
============
|
============
|
||||||
To use a URL to generate a captcha image, you must add the bundle's routing configuration to your app/routing.yml file:
|
To use a URL to generate a captcha image, you must add the bundle's routing configuration to your `config/routes.yaml` file:
|
||||||
|
|
||||||
``` yaml
|
``` yaml
|
||||||
gregwar_captcha_routing:
|
gregwar_captcha_routing:
|
||||||
resource: "@GregwarCaptchaBundle/Resources/config/routing/routing.yml"
|
resource: "@GregwarCaptchaBundle/Resources/config/routing/routing.yml"
|
||||||
```
|
```
|
||||||
|
|
||||||
This will use the bundle's route of "/generate-captcha/{key}" to handle the generation. If this route conflicts with an application route, you can prefix the bundle's routes when you import:
|
This will use the bundle's route of `/generate-captcha/{key}` to handle the generation. If this route conflicts with an application route, you can prefix the bundle's routes when you import:
|
||||||
|
|
||||||
``` yaml
|
``` yaml
|
||||||
gregwar_captcha_routing:
|
gregwar_captcha_routing:
|
||||||
resource: "@GregwarCaptchaBundle/Resources/config/routing/routing.yml"
|
resource: "@GregwarCaptchaBundle/Resources/config/routing/routing.yml"
|
||||||
prefix: /_gcb
|
prefix: /_gcb
|
||||||
```
|
```
|
||||||
|
@ -17,6 +17,7 @@ services:
|
|||||||
arguments:
|
arguments:
|
||||||
- '@gregwar_captcha.generator'
|
- '@gregwar_captcha.generator'
|
||||||
- '%gregwar_captcha.config%'
|
- '%gregwar_captcha.config%'
|
||||||
|
autowire: true
|
||||||
|
|
||||||
# captcha.type:
|
# captcha.type:
|
||||||
gregwar_captcha.type:
|
gregwar_captcha.type:
|
||||||
|
Reference in New Issue
Block a user