Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symfony 5 support, documentation #207

Open
tacman opened this issue Dec 27, 2019 · 23 comments
Open

Symfony 5 support, documentation #207

tacman opened this issue Dec 27, 2019 · 23 comments

Comments

@tacman
Copy link
Contributor

tacman commented Dec 27, 2019

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?

@Olaf1989
Copy link
Contributor

@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

@tacman
Copy link
Contributor Author

tacman commented Dec 28, 2019 via email

@tacman
Copy link
Contributor Author

tacman commented Dec 28, 2019 via email

@Olaf1989
Copy link
Contributor

@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
Copy link
Contributor

Olaf1989 commented Jan 3, 2020

@tacman pull-request added #208

@tacman
Copy link
Contributor Author

tacman commented Jan 3, 2020 via email

@Olaf1989
Copy link
Contributor

Olaf1989 commented Jan 3, 2020

@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.

@Gregwar
Copy link
Owner

Gregwar commented Jan 8, 2020

Merged @Olaf1989 and tagged v2.1.0

@Olaf1989
Copy link
Contributor

Olaf1989 commented Jan 9, 2020

@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

@Gemorroj
Copy link
Contributor

Gemorroj commented Jan 10, 2020

@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?

@vipinbose
Copy link

vipinbose commented Jan 11, 2020

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

Found a solution: Version fixed at 2.0.7

@Olaf1989
Copy link
Contributor

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

@Gregwar
Copy link
Owner

Gregwar commented Jan 14, 2020

@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:
b8a129f

@vipinbose can you confirm ?

I'm ok with more explainations about that

@Gemorroj
Copy link
Contributor

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

@Gregwar
Copy link
Owner

Gregwar commented Jan 15, 2020

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

@vipinbose
Copy link

@Gregwar yes, it fixed Thanks for the support

@vipinbose
Copy link

@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

@Gregwar
Copy link
Owner

Gregwar commented Apr 9, 2020

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

@vipinbose
Copy link

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

Yes yes yes... its working now. Thanks

@Olaf1989
Copy link
Contributor

Olaf1989 commented May 2, 2020

@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 fec0ebb

@Gregwar
Copy link
Owner

Gregwar commented May 3, 2020

@Olaf1989 done, sorry for the delay

@Olaf1989
Copy link
Contributor

Olaf1989 commented Jun 5, 2020

@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.

@tacman
Copy link
Contributor Author

tacman commented Jun 5, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants