doctrinecomposer-phpdoctrine-dbal

Doctrine undefined constant "Doctrine\DBAL\Types\Types::ARRAY"


Whenever I try to make an entity with the php bin/console make:entity command, I get the error when adding a few specific data types like integer.

The error I'm getting is

In DoctrineHelper.php line 262:
Undefined constant Doctrine\DBAL\Types\Types::ARRAY

This error is caught in the console, it has no stack trace further than this.

I've looked up solutions and found that it has to do with the Doctrine version, though I do not know what to upgrade or downgrade it to since I haven't found a solution for this particular error.

My doctrine versions in composer.json:

"doctrine/doctrine-bundle": "^2.11",
"doctrine/doctrine-migrations-bundle": "^3.3",
"doctrine/orm": "^3.0",
...
"symfony/doctrine-messenger": "6.4.*",

I tried upgrading and downgrading the package but got a compatibility error. What versions should I be using?


Solution

  • With the presented require in composer.json:

    {
      "name": "yivi/test_dbal_4",
      "type": "project",
      "autoload": {
        "psr-4": {
          "Yivi\\TestDbal4\\": "src/"
        }
      },
      "require": {
        "doctrine/doctrine-bundle": "^2.11",
        "doctrine/doctrine-migrations-bundle": "^3.3",
        "doctrine/orm": "^3.0",
        "symfony/doctrine-messenger": "6.4.*"
      }
    }
    

    you'll end up installing doctrine/dbal version 4 (just released during the weekend).

    If you are not ready for the bleeding edge, simply add that you want DBAL 3:

    {
      "name": "yivi/test_dbal_4",
      "type": "project",
      "autoload": {
        "psr-4": {
          "Yivi\\TestDbal4\\": "src/"
        }
      },
      "require": {
        "doctrine/doctrine-bundle": "^2.11",
        "doctrine/doctrine-migrations-bundle": "^3.3",
        "doctrine/orm": "^3.0",
        "doctrine/dbal": "^3.8",
        "symfony/doctrine-messenger": "6.4.*"
      }
    }
    

    With this, you'll install doctrine/dbal 3.8, and this particular issue should go away.

    You could also accomplish the same by doing composer require doctrine/dbal:^3.8.

    Also, check if you actually want to install ORM v3, or if you are better served for the time being by remaining on doctrine/orm:^2.