'Symfony/ possibly Doctrine error on any attempts of calling make:entity

On any attempts to call "php bin/console make:entity" I get the following error:

In DoctrineHelper.php line 180:

Class "Doctrine\Persistence\Mapping\Driver\AnnotationDriver" does not exist

I checked vendor, and it appears there is no file called AnnotationDriver.php there but I'm unsure on how to proceed.

using the following:

  "type": "project",
"license": "proprietary",
"require": {
    "php": ">=7.1.3",
    "ext-ctype": "*",
    "ext-iconv": "*",
    "curl/curl": "^2.3",
    "doctrine/annotations": "^1.13",
    "doctrine/doctrine-bundle": "^2.6",
    "doctrine/doctrine-migrations-bundle": "^3.2",
    "doctrine/orm": "^2.11",
    "easycorp/easyadmin-bundle": "*",
    "friendsofsymfony/rest-bundle": "^3.3",
    "guzzlehttp/guzzle": "^7.4",
    "lcobucci/jwt": "*",
    "nelmio/cors-bundle": "^2.2",
    "phpdocumentor/reflection-docblock": "^5.3",
    "sensio/framework-extra-bundle": "^6.2",
    "symfony/asset": "*",
    "symfony/console": "4.4.*",
    "symfony/dotenv": "4.4.*",
    "symfony/expression-language": "4.4.*",
    "symfony/flex": "^1.3.1",
    "symfony/form": "4.4.*",
    "symfony/framework-bundle": "4.4.*",
    "symfony/http-foundation": "4.4.*",
    "symfony/monolog-bundle": "^3.7",
    "symfony/property-access": "4.4.*",
    "symfony/property-info": "4.4.*",
    "symfony/proxy-manager-bridge": "4.4.*",
    "symfony/security-bundle": "4.4.*",
    "symfony/serializer": "4.4.*",
    "symfony/twig-bundle": "4.4.*",
    "symfony/validator": "4.4.*",
    "symfony/yaml": "4.4.*"
}

in my composer.json. I tried upgrading and downgrading doctrine/orm but it didn't help.



Solution 1:[1]

If you use Maven to build your application, you should put the my-config.xml file to src/main/resources directory

Solution 2:[2]

ok, I found a solution. So I created a resources directory under src/main and placed my my-config.xml there. After it started working

Solution 3:[3]

You are using Spring's ClassPathXmlApplicationContext class. As the name of the class implies (and the javadoc says) this loads its config files from the application classpath.

But the contents of the src/main/java tree are not on the classpath. Put the file into src/main/resources ... which will (typically) be added directly to the classpath directly, or added to the JAR or WAR file that Maven / Gradle / your IDE generates.

See also:


I tried to place my-config.xml under src/main/java as some of the articles suggest, still no luck.

Yea ... no. Unless you do other (probably inadvisable) things, files in the src/main/java are not on the classpath, and won't be found by ClassPathXmlApplicationContext.

If those articles really suggested this as a solution for this context, then they are just plain wrong. That approach could sort of work if you were using FileSystemXmlApplicationContext ... but using a relative pathname is fragile (it depends on what the app's working directory is), and a pathname that refers to your source tree typically won't work when you deploy your application in production.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Z. Alex
Solution 2 Dima
Solution 3