Symfony2 bundle to generate model or interface class
Symfony2 bundle to generate model or interface class, (*1)
2. Run "composer update" 3. Make sure to enable PandoraDoctrineGeneratorBundle in AppKernel.php . ``` php public function registerBundles() { $bundles = array( // ... new Pandora\DoctrineGeneratorBundle\PandoraDoctrineGeneratorBundle(), ); }
php app/console doctrine:generate:model --model=YourBundle:Blog/Post
The above command would initialize a new model in the following model namespace Acme\BlogBundle\Model\Blog\Post, (*2)
You can also optionally spectify the fields you want to generate in the new model:, (*3)
php app/console doctrine:generate:model --model=YourBundle:Blog/Post --fields="title:string(255) body:text"
The command can also generate the corresponding entity repository class with the --with-repository option:, (*4)
php app/console doctrine:generate:model --model=YourBundle:Blog/Post --with-repository
By default, the command uses annotations for the mapping information; change it with --format:, (*5)
php app/console doctrine:generate:model --model=YourBundle:Blog/Post --format=yml
To generate or update the corresponding entity class, use the --with-entity option:, (*6)
php app/console doctrine:generate:model --model=YourBundle:Blog/Post --with-entity
To generate the corresponding interface class, use the --with-interface option:, (*7)
php app/console doctrine:generate:model --model=YourBundle:Blog/Post --with-interface
php app/console doctrine:generate:models YourBundle
php app/console doctrine:generate:models YourBundle:User php app/console doctrine:generate:models Your/Bundle/Model/User
php app/console doctrine:generate:models YourBundle/Model
If the entities are not stored in a bundle, and if the classes do not exist, the command has no way to guess where they should be generated. In this case, you must provide the --path option:, (*8)
php app/console doctrine:generate:models Your/Bundle/Model --path=src/
By default, the unmodified version of each model is backed up and saved (e.g. Product.php~). To prevent this task from creating the backup file, pass the --no-backup option:, (*9)
php app/console doctrine:generate:models Your/Bundle/Model --no-backup
To generate or update the corresponding entity class, use the --with-entity option:, (*10)
php app/console doctrine:generate:models YourBundle --with-entity
To generate the corresponding interface class, use the --with-interface option:, (*11)
php app/console doctrine:generate:models YourBundle --with-interface
Important: Even if you specified Inheritance options in your XML or YAML Mapping files the generator cannot generate the base and child classes for you correctly, because it doesnot know which class is supposed to extend which. You have to adjust the model code manually for inheritance to work!, (*12)