Skip to content

Instantly share code, notes, and snippets.

@extraordinaire
Created September 4, 2010 15:24
Show Gist options
  • Save extraordinaire/565268 to your computer and use it in GitHub Desktop.
Save extraordinaire/565268 to your computer and use it in GitHub Desktop.
Patch for Symfony2 doctrine:generate:entity
diff --git a/src/Symfony/Bundle/DoctrineBundle/Command/GenerateEntityDoctrineCommand.php b/src/Symfony/Bundle/DoctrineBundle/Command/GenerateEntityDoctrineCommand.php
index 6100d31..444921e 100644
--- a/src/Symfony/Bundle/DoctrineBundle/Command/GenerateEntityDoctrineCommand.php
+++ b/src/Symfony/Bundle/DoctrineBundle/Command/GenerateEntityDoctrineCommand.php
@@ -71,7 +71,7 @@ EOT
}
$entity = $input->getArgument('entity');
- $entityNamespace = $namespace.'\\'.$bundle.'\\Entities';
+ $entityNamespace = $namespace.'\\'.$bundle.'\\Entity';
$fullEntityClassName = $entityNamespace.'\\'.$entity;
$tmp = str_replace('\\', '/', $fullEntityClassName);
$tmp = str_replace('/', '\\', dirname($tmp));
@extraordinaire
Copy link
Author

The entity namespace should end in "Entity" instead of "Entities", otherwise the following exception is thrown:

php symfony doctrine:generate:entity "Bundle\MyCustomBundle" "User\Group" --fields="name:string(255) description:text"
php symfony doctrine:generate:entities
[Doctrine\ORM\Mapping\MappingException]                                                       
  Class Bundle\MyCustomBundle\Entities\User\Group is not a valid entity or mapped super class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment