Diary of problems and solutions related to web programming, database development and related technologies and platforms.

Creating and removing Doctrine Entity using Symfony2 (Creating CRUD Application)

Creating Doctrine Entity

Open up the command line Git Bash

Go to the project folder
$ cd C:/wamp/www/Symfony2Project

Run the following command to create doctrine entity
php app/console generate:doctrine:entity

This entity helps to create class properties, getters and setters functions.

Entity shortcut name: AcmeDemoBundle:Product
Configuration format: yml

New field name: title
Field type (string): Enter
Field length [255]:100

New field name: price
Field type (string): float

New field name: (If you do not want to add extra field names, then press Enter)
Do you want to generate an empty repository class [no]? Enter
Do you want to confirm generation [yes]? Enter 

Removing Entity

- Delete Product.php file inside src/Acme/DemoBundle/Entity folders
- Delete Product.orm.yml file inside src/Acme/DemoBundle/Resources/config/doctrine folders

Reference: http://symfony.com/doc/current/bundles/SensioGeneratorBundle/commands/generate_doctrine_entity.html

No comments :

Post a Comment