CaptchaBundle icon indicating copy to clipboard operation
CaptchaBundle copied to clipboard

Symfony 5 support, documentation

Open tacman opened this issue 6 years ago • 23 comments

I'm having a hard time getting this bundle to work with Symfony 5.

First, services.yml needs to have quotes around the parameter:

services:
    # captcha type
    captcha.type:
        class: Gregwar\CaptchaBundle\Type\CaptchaType
        arguments: [ "@session", '%gregwar_captcha.config%' ]
        tags:
            - { name: form.type, alias: captcha }

But the issue I can't figure out is how to configure it. I've tried adding things to my services.yaml file, but no luck.

gregwar_captcha:
    width: 200
    height: 50
    length: 6

OR

gregwar_captcha: ~

How and where is the config defined for Symfony 5?

tacman avatar Dec 27 '19 16:12 tacman

@tacman you can create a configuration file in config/packages/ for example named gregwar_captcha.yaml.

For the configuration you should change the web_path option, because it is using an old Symfony default '%kernel.root_dir%/../web'.

gregwar_captcha:
  web_path: '%kernel.project_dir%/public'

The configuration is automatically loaded because the key matches the bundle in lower case and without the word 'bundle'. Read more: https://symfony.com/doc/current/bundles/configuration.html#processing-the-configs-array

Olaf1989 avatar Dec 28 '19 14:12 Olaf1989

Yep. Can you add a recipe to the Symfony flex repository for this.

TreeBuilder doesn't work, I'll fix it and submit a PR.

On Sat, Dec 28, 2019 at 9:45 AM Olaf [email protected] wrote:

@tacman https://github.com/tacman you can create a configuration file in config/packages/ for example named gregwar_captcha.yaml.

For the configuration you should change the web_path option, because it is using an old Symfony default '%kernel.root_dir%/../web'.

gregwar_captcha: web_path: '%kernel.project_dir%/public'

The configuration is automatically loaded because the key matches the bundle in lower case and without the word 'bundle'. Read more: https://symfony.com/doc/current/bundles/configuration.html#processing-the-configs-array

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Gregwar/CaptchaBundle/issues/207?email_source=notifications&email_token=AAEXIQIZNZ7AZS3RNMH2ULDQ25Q7BA5CNFSM4J76OVG2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHYLIRY#issuecomment-569422919, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEXIQMM2MIPYUDVYVN2EBTQ25Q7BANCNFSM4J76OVGQ .

tacman avatar Dec 28 '19 15:12 tacman

I see you've fixed it already. Can you bump a new version (2.1?).

Personally, I'd suggest bumping to a Version 3 that only supports Symfony 4.4+. It'll make a few things easier (like documentation), and anyone using 3.4 can continue to use version 2 (or 2.1 if you bump what you have now).

On Sat, Dec 28, 2019 at 10:12 AM Tac Tacelosky [email protected] wrote:

Yep. Can you add a recipe to the Symfony flex repository for this.

TreeBuilder doesn't work, I'll fix it and submit a PR.

On Sat, Dec 28, 2019 at 9:45 AM Olaf [email protected] wrote:

@tacman https://github.com/tacman you can create a configuration file in config/packages/ for example named gregwar_captcha.yaml.

For the configuration you should change the web_path option, because it is using an old Symfony default '%kernel.root_dir%/../web'.

gregwar_captcha: web_path: '%kernel.project_dir%/public'

The configuration is automatically loaded because the key matches the bundle in lower case and without the word 'bundle'. Read more: https://symfony.com/doc/current/bundles/configuration.html#processing-the-configs-array

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Gregwar/CaptchaBundle/issues/207?email_source=notifications&email_token=AAEXIQIZNZ7AZS3RNMH2ULDQ25Q7BA5CNFSM4J76OVG2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHYLIRY#issuecomment-569422919, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEXIQMM2MIPYUDVYVN2EBTQ25Q7BANCNFSM4J76OVGQ .

tacman avatar Dec 28 '19 15:12 tacman

@tacman i'm a bit busy, but i have made some quick changes i will try to test this soon.

I will add the recipe to Symfony flex after there is a release version available, this is necessary https://github.com/symfony/recipes/blob/master/README.rst#creating-recipes

Olaf1989 avatar Dec 29 '19 23:12 Olaf1989

@tacman pull-request added https://github.com/Gregwar/CaptchaBundle/pull/208

Olaf1989 avatar Jan 03 '20 00:01 Olaf1989

Thanks! Sorry to ask such a dumb question, but how can I test this?

composer require gregwar/captcha-bundle:@symfony-5

isn't working, but I know it's something like that.

On Thu, Jan 2, 2020 at 7:13 PM Olaf [email protected] wrote:

@tacman https://github.com/tacman pull-request added #208 https://github.com/Gregwar/CaptchaBundle/pull/208

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Gregwar/CaptchaBundle/issues/207?email_source=notifications&email_token=AAEXIQIA6AV2CAJEILN3EXTQ3Z7LRA5CNFSM4J76OVG2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEH74LHA#issuecomment-570410396, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEXIQK4YEXAJOYOKCHOGJTQ3Z7LRANCNFSM4J76OVGQ .

tacman avatar Jan 03 '20 00:01 tacman

@tacman i have no idea if it is possible, let alone how.

It is possible to copy the contents of https://github.com/Olaf1989/CaptchaBundle/tree/symfony-5 and use it as a symbolic (vendor/gregwar/captcha-bundle) link in your local project to test it.

Olaf1989 avatar Jan 03 '20 00:01 Olaf1989

Merged @Olaf1989 and tagged v2.1.0

Gregwar avatar Jan 08 '20 15:01 Gregwar

@Gregwar thank you!

@tacman a Symfony recipe is not needed anymore because the default configuration is valid. Otherwise we should move all default values (from https://github.com/Gregwar/CaptchaBundle/blob/master/DependencyInjection/Configuration.php) to the recipe

Olaf1989 avatar Jan 09 '20 19:01 Olaf1989

@Gregwar , @Olaf1989 have error with 2.1 release (symfony 4.4) config:

gregwar_captcha:
    as_url: true
    reload: true

generated path:

/_gcbw/generate-captcha/_captcha_captcha?n=48d1ffaf109bcac63087aac19c90de83

error:

The controller for URI "/_gcbw/generate-captcha/_captcha_captcha" is not callable. Controller "Gregwar\CaptchaBundle\Controller\CaptchaController" has required constructor arguments and does not exist in the container. Did you forget to define the controller as a service?

Gemorroj avatar Jan 10 '20 11:01 Gemorroj

@Gemorroj I am also facing this issue. Any solution for this

Found a solution: Version fixed at 2.0.7

vipinbose avatar Jan 11 '20 11:01 vipinbose

@Gemorroj i'm a bit too busy at the moment, but when i have time i will look into it.

Olaf1989 avatar Jan 13 '20 19:01 Olaf1989

@Gemorroj @Olaf1989 I don't really understand why this doesn't work with 4.4

Looks like adding the controller as service id fixes the issue, I pushed on master: https://github.com/Gregwar/CaptchaBundle/commit/b8a129fc2a3a1a2cede5bd8942cd86988334fce8

@vipinbose can you confirm ?

I'm ok with more explainations about that

Gregwar avatar Jan 14 '20 10:01 Gregwar

@Gregwar yes, this commit fixes the problem for me.

Gemorroj avatar Jan 14 '20 22:01 Gemorroj

OK, I'm afraid I can't exactly explain the reason of this problem, but I can't investigate any further right now I tagged v2.1.1 to be sure this fix is included for 4.4 users

Gregwar avatar Jan 15 '20 09:01 Gregwar

@Gregwar yes, it fixed Thanks for the support

vipinbose avatar Jan 16 '20 13:01 vipinbose

@Gregwar @tacman @Olaf1989 @Gemorroj I am finding it difficult to make it work in Symfony 5 with following error "Gregwar\CaptchaBundle\Controller\CaptchaController" has no container set, did you forget to define it as a service subscriber?

However if I am not using as_url it works.

Any thoughts ? I tried both gregwar/captcha-bundle dev-master cdbe566 gregwar/captcha-bundle 2.1.2

vipinbose avatar Apr 09 '20 03:04 vipinbose

@vipinbose just pushed on master, is it ok now?

Gregwar avatar Apr 09 '20 08:04 Gregwar

@vipinbose just pushed on master, is it ok now?

Yes yes yes... its working now. Thanks

vipinbose avatar Apr 09 '20 08:04 vipinbose

@Gregwar could you also create a new release for this? For example 2.1.3. The next commit will only come back on master but not in a release https://github.com/Gregwar/CaptchaBundle/commit/fec0ebb2f1a5b6f3a9fa5a5fa2aed24699445839

Olaf1989 avatar May 02 '20 12:05 Olaf1989

@Olaf1989 done, sorry for the delay

Gregwar avatar May 03 '20 10:05 Gregwar

@tacman @Gregwar can either of you close this problem? It all seems to be working now and we can clean up the closed issues a bit more.

Olaf1989 avatar Jun 05 '20 14:06 Olaf1989

Sure, lemme put together a quick demo, should be able to get to it tomorrow.

Tac

On Fri, Jun 5, 2020 at 10:03 AM Olaf [email protected] wrote:

@tacman https://github.com/tacman @Gregwar https://github.com/Gregwar can either of you close this problem? It all seems to be working now and we can clean up the closed issues a bit more.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Gregwar/CaptchaBundle/issues/207#issuecomment-639507009, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEXIQNGWTVRL3A2J2GAY5LRVD3MFANCNFSM4J76OVGQ .

tacman avatar Jun 05 '20 22:06 tacman