excelwebzone / EWZRecaptchaBundle

This bundle provides easy reCAPTCHA form field for Symfony.
MIT License
395 stars 160 forks source link

Fix compatibility with Symfony 4 #188

Closed jmsche closed 6 years ago

jmsche commented 6 years ago

When trying to install the bundle for Symfony 4, the following error is thrown:

You have requested a non-existent parameter "templating.engines".

tibo6 commented 6 years ago

And I have

You have requested a non-existent parameter "twig.form.resources".

someniatko commented 6 years ago

I fixed this for myself by creating config/ewz_recaptcha.yaml wich the following content:

parameters:
    templating.engines: [ 'twig' ]
    twig.form.resources: []

ewz_recaptcha:
    public_key: ''
    private_key: ''
jmsche commented 6 years ago

Templating component seems to be deprecated. Then Twig should be called directly instead of specifying extra config.

bobvandevijver commented 6 years ago

In my project I needed to do the following in order to make it work (which is probably caused by the custom form_theme used):

twig:
  form_themes:
    - "@EWZRecaptcha/Form/ewz_recaptcha_widget.html.twig"
    - "form/form_layout.html.twig"

Next to that, make sure to set the parameter used to determine the engine so that it will not load anything by itself (as it breaks):

parameters:
  templating.engines: [ 'none' ]

Edit: Removed the namespace alias as I found that you need to reference the bundle without the Bundle postfix.

nesl247 commented 6 years ago

Also the old syntax of Bundle:Path:To:File.html.twig is deprecated, instead the @Bundle/Path/To/File.html.twig should be used. Without this change, we currently cannot use Symfony 3.4+'s new default_path for overriding template files. See https://github.com/symfony/symfony/issues/25661

nesl247 commented 6 years ago

@excelwebzone should I raise another issue about the syntax?

excelwebzone commented 6 years ago

No need, I just merged the fix in #196 and tagged it.

nesl247 commented 6 years ago

The fix has nothing to do with https://github.com/excelwebzone/EWZRecaptchaBundle/issues/188#issuecomment-355085803

excelwebzone commented 6 years ago

Sure go ahead and submit a PR and I will review it and merge if good.

bobvandevijver commented 6 years ago

I just found that when you use the templating.engines: [ 'none' ] in your parameters, the error messages in the production environment will break.

Unfortunately, you can not leave it out, as otherwise you cannot use this bundle with the new Twig syntax...