KaSkuLL
KaSkuLL

Reputation: 551

Symfony Entities console error generate

Hi there i would like to create entities by console but give me an error i can't solve.

I've reading a lot about this error but i can't fix it.

1.-

php bin/console generate:bundle

2.-

php bin/console doctrine:mapping:convert xml ./src/BlogBundle/Resources/config/doctrine/metadata/orm --from-database --force

3.-

php bin/console doctrine:mapping:import BlogBundle yml

4.-

php bin/console doctrine:generate:entities BlogBundle

And the error is on 4th step:

C:\x\x\x\x\projecte>php bin/console doctrine:generate:entities BlogBundle:User


  [Doctrine\ORM\ORMException]
  Unknown Entity namespace alias 'BlogBundle'.


doctrine:generate:entities [--path PATH] [--no-backup] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> <name>

PD: i'm using symfony 3.3

Upvotes: 1

Views: 910

Answers (2)

Oscar
Oscar

Reputation: 2047

I use this commands to generate entities:

  1. php bin/console doctrine:mapping:import --force AppBundle --env=local --em=myentityManager
  2. php bin/console doctrine:mapping:convert annotation ./src --env=local --em=entityManager
  3. Delete orm.xml Files generated
  4. php bin/console doctrine:generate:entities AppBundle:User --env=local

Upvotes: 1

Stas Parshin
Stas Parshin

Reputation: 1693

By Symfony conventions, the BlogBundle namespace goes under your company or project name (e.g. Acme\BlogBundle). So your BlogBundle should be prefixed with the company name like this:

C:\x\x\x\x\projecte>php bin/console doctrine:generate:entities AcmeBlogBundle:User

Just replace Acme with whatever subfolder your BlogBundle lives under and it should work.

Upvotes: 0

Related Questions