当前位置:网站首页>Symfony3.4 数据库反向生成entity 已解决
Symfony3.4 数据库反向生成entity 已解决
2022-04-22 10:16:00 【PHP代码】
映射数据库结构到文件(php\xml\yaml)
### 映射数据库结构到文件(php\xml\yaml)
[root@localhost ~]# cd /windows/www/symfony_test/
[root@localhost symfony_test]# php bin/console doctrine:mapping:import --force AppBundle php
Importing mapping information from "default" entity manager
> writing /windows/www/symfony_test/src/AppBundle/Resources/config/doctrine/Feedback.orm.php
> writing /windows/www/symfony_test/src/AppBundle/Resources/config/doctrine/User.orm.php
> writing /windows/www/symfony_test/src/AppBundle/Resources/config/doctrine/User.orm.php
### 生成entity
[root@localhost symfony_test]# php bin/console doctrine:mapping:convert annotation ./src
Processing entity "AppBundle\Entity\Feedback"
Processing entity "AppBundle\Entity\User"
Processing entity "AppBundle\Entity\User"
Exporting "annotation" mapping information to "/windows/www/symfony_test/src"
[root@localhost symfony_test]#
[root@localhost symfony_test]# tree src/
src/
└── AppBundle
├── AppBundle.php
├── Controller
│ ├── DefaultController.php
│ └── UserController.php
├── Entity
│ └── User.php
├── Repository
│ ├── DemoRepository.php
│ └── UserRepository.php
├── Resources
│ └── config
│ └── doctrine
│ ├── User.orm.php
└── Serverice
└── UserService.php
entity生成后,需要自己使用IDE工具生成getters和setters方法, 以及一些关联关系, 验证Assert提示信息
注意entity定义字段的格式,@var string|null必须要写,不然会找不到该字段
php bin/console doctrine:generate:entities AppBundle/Entity/Users
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* User
*
* @ORM\Table(name="user")
* @ORM\Entity
* @ORM\Entity(repositoryClass="AppBundle\Repository\UserRepository")
*/
class User
{
/**
* @var string|null
*
* @ORM\Column(name="name", type="string", length=100, nullable=true)
*/
private $name;
/**
* @var bool|null
*
* @ORM\Column(name="enabled", type="boolean", nullable=true, options={"default"="1"})
*/
private $enabled = '1';
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
}
php bin/console doctrine:mapping:import --force RelBundle annotation
生成get,set 自定义库
php bin/console doctrine:generate:entities RelBundle
php app/console doctrine:mapping:import "YourAppBundle" annotation --em=show --filter=DownloadRankingCoefficient
php app/console doctrine:generate:entities --no-backup YourAppBundle:DownloadRankingCoefficient
版权声明
本文为[PHP代码]所创,转载请带上原文链接,感谢
https://blog.csdn.net/vcit102/article/details/123876806
边栏推荐
- openEuler Kernel 技术解读 | 内核中断子系统介绍
- IOS development - Database - Introduction to basic knowledge (01)
- 【无标题】
- Transform based deep learning target detection (Detr model)
- JWT source code analysis (four layer package with schematic diagram)
- [age appropriate friends of interesting programming questions] (detailed explanation of the original title of leetcode)
- getimagesize()函数获取图片宽高取反
- 多目标追踪——拓展卡尔曼滤波(EKF)
- 头条面试居然跟我扯了半小时的Semaphore
- SQL relational database management system
猜你喜欢
![[SQL Server] SQL overview](/img/96/b762b1e80225fa5324b945dea2f427.jpg)
[SQL Server] SQL overview

Error message during unity3d build: missing project ID in unity solution

通过LayerDrawable实现进度条的功能

Multi target tracking extended Kalman filter (EKF)

MySQL隐式转换案例一则

oracle19. 3 upgrade to 19.6

中商惠⺠交易中台架构演进:对 Apache ShardingSphere 的应⽤

Unity3D build时错误提示:Missing Project ID in Unity 解决方案

Film online ticket purchase system based on SSM

dataguard (ADG)备库移动(迁移)数据文件
随机推荐
shell获取随机数和echo -e '\033[字背景颜色;字体颜色m字符串\033[0m'
oracle19.3升级到19.6
How to realize synchronous monitoring of etcd
*CTF 2022 Reverse Writeup
The VirtualBox virtual machine uses virtio net to run dpdk + VPP and cannot receive VLAN messages
Idea writes sparksql program in local [*] mode, which can be run. Classnotfoundexception occurs when it is submitted to spark yarn for running
01背包问题——以及变形问题
浅析图片懒加载(三种实现方法与两种优化方式)
JWT source code analysis (four layer package with schematic diagram)
Analysis of image lazy loading (three implementation methods and two optimization methods)
三分钟快速了解互动涂鸦
多语言通信基础 05 go的grpc体验
Google Earth Engine(GEE)——聚合网格化人口数据
Cloud leopard intelligence, a DPU chip head enterprise, joined the openeuler community to help Digital China infrastructure
MySQL隐式转换案例一则
docker 启动mysql问题,You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQ
Windows下oracle11.2.0.1升级至oracle11.2.0.4
Meituan side: have you used jstat, jmap, mat in the production time? Can you give me a practical example?
Zhongshanghui ⺠ evolution of trading platform architecture: response to Apache shardingsphere
linux安装oracle19c完整版(图形+静默安装)