Why my symfony captcha always return valid?

  captcha, php, recaptcha, symfony, symfony4

I followed this tutorial to add a captcha to my form.

First I install it using

composer require captcha-com/symfony-captcha-bundle:"4.*"

After I Install it, I got an error on a file called captcha.html.twig

captcha Unexpected "spaceless" tag (expecting closing tag for the
"block" tag defined near line 2).

So I changed {% spaceless %} to {% apply spaceless %}
And the error is gone.

But My captcha bot always returns True (even when I don’t even fill it.
Here is the ->add() function of my form:

->add('captchaCode', CaptchaType::class, [
    'captchaConfig' => 'ExampleCaptchaUserRegistration',
    'constraints' => [
        new ValidCaptcha([
            'message' => 'Invalid captcha, please try again',

Code of Routes.yaml :

    resource: "@CaptchaBundle/Resources/config/routing.yml"

Code of captcha.php :

// app/config/packages/captcha.php
if (!class_exists('CaptchaConfiguration')) { return; }

// BotDetect PHP Captcha configuration options
return [
    // Captcha configuration for example form
    'ExampleCaptchaUserRegistration' => [
        'UserInputID' => 'captchaCode',
        'ImageWidth' => 250,
        'ImageHeight' => 50,

Captcha field on the User.php entity:

protected $captchaCode;

public function getCaptchaCode()
  return $this->captchaCode;

public function setCaptchaCode($captchaCode)
  $this->captchaCode = $captchaCode;

Code in the View (twig)

<span class="txt1 p-b-11">
    Are You a Robot?
<div class="wrap-input100 m-b-36">
    {{ form_widget(form.captchaCode, {'attr': {'class': 'input100'} }) }}       
    <span class="focus-input100"></span>
<div class="error">{{ form_errors(form.captchaCode) }} </div>

Source: Symfony Questions