After two days of contact, I found that symfony is really awesome. I was confused about which one is better, laravel or symfony. After learning laravel for a week, I found that there were too few documentation and learning materials. I immediately turned to symfony and discovered that it has the same functions as laravle. It’s almost the same, so I didn’t watch Laravle in vain the past week. But today I found a very good function, which is more similar to Java. I was happy for a while. Let me share with you how to automatically generate database table entities with just a few clicks like Java.
I use Symfony3.0, generates certain connection database configuration information for database entities. The connection configuration information is in the app/config/parameters.yml file. Symfony will automatically identify which database it is. If you want to study it carefully, check out the documentation! I was also drunk when talking about the document. I copied every sentence into Baidu Translate to understand the meaning.
Generate entities from database table
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 needs to change the first line of path, otherwise the following error will be reported in the instance table structure:)
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
The above is the detailed content of An explanation of how symfony generates database table entities and migrates databases. For more information, please follow other related articles on the PHP Chinese website!