Symfony how to generate database table entities and migrate databases

Source: Internet
Author: User

Two days of contact found Symfony really pretty cow broke, before the tangled Laravel or symfony which a good point, learned laravel one weeks found that the document learning material is too little, and immediately turned to Symfony found him and laravle function almost, So the laravle that I had seen one weeks ago didn't look white. But today found a very good function, more Java almost, happy for a while, the following to share, how to like Java automatically a few clicks, automatically generated the database table entity

I am using symfony3.0, generate database Entity positive Connection database configuration information, connection configuration information in the App/config/parameters.yml file Symfony will automatically identify what database, want to study carefully to read the document it! said the document I am also drunk, a word a word copy to Baidu translation inside understand meaning.

Generating entities from a database table

1. Generated by the database model: PHP bin/console doctrine:mapping:convert--from-database yml D:\db\
d:\test_backend>php bin/console Doctrine:mapping:convert--from-database yml D:\db\Processing entity "Appuser" Processing entity "Channel" processing entity "migrationversions" exporting "yml" mapping Information to "D:\DB"

(The model to change the first line of the path, or in the instance table structure will be error as follows:)

Invalid mapping file ' AppBundle.Entity.AppUser.orm.yml ' for class ' Appbundle\entity\appuser '. Example:app_ The model of the user table generates the first behavior: ' Appuser: '; To change this to "Appbundle\entity\appuser:" Fish 2. Instance All table structure table structure file copied to: Appbundle\resources\config \doctrine php bin/console doctrine:generate:entities appbundle/entity/--path src/Instance single table structure (sitechannel) PHP bin/console Doctrine:generate:entities Appbundle/entity/sitechannel--path src/
d:\test_backend>php bin/console doctrine:generate:entities appbundle/entity/appuser--path src/generating Entities for Namespace "Appbundle\entity\appuser"  > Backing up appuser.php to appuser.php~  > generating Appbundle\entity\appuser
Database migration (Symfony local Migration to database): Turn on database migration: Composer require doctrine/doctrine-migrations-bundle "^1.0" entity update to Database resources->entity (Compare) PHP bin/console Doctrine:migrations:diff (migration) PHP bin/console doctrine:migrations:migrate
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.