简体   繁体   中英

Doctrine mapping a class that doesn't exist

I just re-installed Symfony2 and Doctrine. It's brand new.

Now I generate an entity (called account), put some simple annotation and then want to update my schema. And then:

 [Doctrine\Common\Persistence\Mapping\MappingException]               
 Class 'NRtworks\ChartOfAccountsBundle\Entity\Nathan' does not exist

But I don't have no class called Nathan (ok it's my firstname).Not anywhere in any bundle I currently have. I've had one like that but in another Symfony2 install.

Now when I create one entity named "Nathan" it works, but then it creates a schema that is not related.

Now my question is where doctrine can store "ghosts" entities ? I have tried to clear all the caches of doctrine & Symfony2 but it does not change anything.

i had the same problem, i solved this issue after adding autoloading-line to my composer.json:

{ "require": { "doctrine/orm": " ", "symfony/yaml": " " }, "autoload": { "psr-0": {"": "config/yml/"}, // here stay my yml-schema files "psr-0": {"": "Entity/"} // my generated entity-files } }

after editing file, just execute "composer update" in youre project path, the autoloader-classes will be regenerated with the new autoloader-path. then you can generate entity-model files or do anything else.. hope this help!

change

"psr-0": { "": "Entity/" } // my generated entity-files

to

"psr-0": { "": "src/" } // my generated entity-files

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM