首頁 後端開發 php教程 Doctrine248 命令列工具產生yml/xml/entities

Doctrine248 命令列工具產生yml/xml/entities

Jul 29, 2016 am 08:58 AM
convert database doctrine entities

Doctrine2壓縮包的tools目錄用來做一些命令列工作。這裡主要說一下透過tools,把資料庫的表結構自動產生yml/xml/entities,原因是寫那些東西太浪費時間了有木有。

1.透過Doctrine 的orm:convert-mapping指令產生xml/yml

Usage:
  orm:convert-mapping [options] [--] <to-type> <dest-path>
  orm:convert:mapping

Arguments:
  to-type                        The mapping type to be converted.
  dest-path                      The path to generate your entities classes.

Options:
      --filter=FILTER            A string pattern used to match entities that should be processed. (multiple values allowed)
      --force                    Force to overwrite existing mapping files.
      --from-database            Whether or not to convert mapping information from existing database.
      --extend[=EXTEND]          Defines a base class to be extended by generated entity classes.
      --num-spaces[=NUM-SPACES]  Defines the number of indentation spaces [default: 4]
      --namespace[=NAMESPACE]    Defines a namespace for the generated entity classes, if converted from database.
  -h, --help                     Display this help message
  -q, --quiet                    Do not output any message
  -V, --version                  Display this application version
      --ansi                     Force ANSI output
      --no-ansi                  Disable ANSI output
  -n, --no-interaction           Do not ask any interactive question
  -v|vv|vvv, --verbose           Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Help:
 Convert mapping information between supported formats.
 
 This is an execute one-time command. It should not be necessary for
 you to call this method multiple times, especially when using the --from-database
 flag.
 
 Converting an existing database schema into mapping files only solves about 70-80%
 of the necessary mapping information. Additionally the detection from an existing
 database cannot detect inverse associations, inheritance types,
 entities with foreign keys as primary keys and many of the
 semantical operations on associations such as cascade.
 
 Hint: There is no need to convert YAML or XML mapping files to annotations
 every time you make changes. All mapping drivers are first class citizens
 in Doctrine 2 and can be used as runtime mapping for the ORM.
 
 Hint: If you have a database with tables that should not be managed
 by the ORM, you can use a DBAL functionality to filter the tables and sequences down
 on a global level:
 
     $config->setFilterSchemaAssetsExpression($regexp);
登入後複製

上面是help,下面來一個實例

/var/www/doctrine下面(有的菜鳥問了,cd是個什麼東東,為毛是這個目錄~~cd是什麼呢,拜拜,這種問題百度去。為什麼是這個目錄呢,這是項目文件夾,總之這下面就有doctrine的包了)。前面指令省略解釋,解釋後面的「xml」意思是產生的檔案類型,「config/xml/」是xml存放目錄 ,--from-database的意思是從資料庫產生。 2.生成yml了,然後就要生成entities了

/var/www/doctrine$ php vendor/bin/doctrine orm:convert-mapping xml config/xml/ --from-database
登入後複製
 這個簡單,我的entities放在

/var/www/doctrine/src下面,純粹測試用,後期架構會變化的要先生成yml再生成entities,無法直接生成entities,反正我沒成功,可能操作問題?

PHP ORM這篇文章太少了,因為這篇不常用,說白了PHP ORM卵用不大,純粹方便

以上就介紹了Doctrine248 命令列工具產生yml/xml/entities,包含了方面的內容,希望對PHP教學有興趣的朋友有幫助。

本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

<🎜>:泡泡膠模擬器無窮大 - 如何獲取和使用皇家鑰匙
3 週前 By 尊渡假赌尊渡假赌尊渡假赌
北端:融合系統,解釋
3 週前 By 尊渡假赌尊渡假赌尊渡假赌
Mandragora:巫婆樹的耳語 - 如何解鎖抓鉤
3 週前 By 尊渡假赌尊渡假赌尊渡假赌

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

熱門話題

Java教學
1664
14
CakePHP 教程
1423
52
Laravel 教程
1321
25
PHP教程
1269
29
C# 教程
1249
24
discuz database error怎麼解決 discuz database error怎麼解決 Nov 20, 2023 am 10:10 AM

discuz database error的解決方法有:1、檢查資料庫配置;2、確保資料庫伺服器正在運作;3、檢查資料庫表狀態;4、備份資料;5、清理快取;6、重新安裝Discuz;7、檢查伺服器資源;8、聯繫Discuz官方支持。解決Discuz資料庫錯誤需要從多個方面入手,逐步排除問題原因,並採取相應的措施進行修復。

洩漏揭示了英特爾 Arrow Lake-U、-H、-HX 和 -S 的關鍵規格 洩漏揭示了英特爾 Arrow Lake-U、-H、-HX 和 -S 的關鍵規格 Jun 15, 2024 pm 09:49 PM

英特爾ArrowLake預計將基於與LunarLake相同的處理器架構,這意味著英特爾全新的LionCove效能核心將與經濟體的Skymont效率核心結合。

物件關係映射(ORM)基礎:了解Doctrine ORM 物件關係映射(ORM)基礎:了解Doctrine ORM Jun 19, 2023 pm 03:43 PM

物件關聯映射(ORM)基礎:了解DoctrineORM當我們開發應用程式的時候,我們需要對資料庫進行操作來儲存和獲取資料。但是,直接使用原始的資料庫查詢程式碼很不方便。我們需要將物件和資料之間建立映射關係,這就是ORM的作用。 ORM將物件和資料庫表之間自動進行對應和轉換,可以輕鬆地進行資料操作,使得我們的程式碼更容易維護。 DoctrineORM是PHP

誤用html entities函數引發的漏洞怎麼解決 誤用html entities函數引發的漏洞怎麼解決 May 12, 2023 pm 02:13 PM

題目程式碼如下:漏洞解析:根據題目意思,這裡考察的應該是xss漏洞,漏洞觸發點應該在程式碼中的第13-14行。這兩行程式碼的作用是直接輸出一個html的標籤。程式碼中的第3-5行,foreach迴圈對$_GET傳入的參數進行了處理,但這裡有個問題。我們看下第四行的程式碼,這行程式碼針對$value進行型別轉換,強制變成int型別。但這部分程式碼只處理了$value變量,沒針對$key變數進行處理。經過了第3-5行的程式碼處理之後,依照&這個符號進行分割,然後拼接到第13行的echo語句中,在輸出的

Can't drop database 'database_name'; database doesn't exist - 如何解決MySQL錯誤:無法刪除資料庫,資料庫不存在 Can't drop database 'database_name'; database doesn't exist - 如何解決MySQL錯誤:無法刪除資料庫,資料庫不存在 Oct 05, 2023 am 11:46 AM

如何解決MySQL報錯:無法刪除資料庫,資料庫不存在概述:MySQL是一種常用的關係型資料庫管理系統。在使用MySQL中,我們經常需要對資料庫進行管理,包括建立資料庫、刪除資料庫等操作。然而,在刪除資料庫時,有時會遇到報錯提示"Can'tdropdatabase'database_name';databasedoesn'texist",即無法刪

convert是什麼軟體 convert是什麼軟體 Dec 09, 2020 am 09:33 AM

convert不是軟體,而是在Windows中的檔案bai系統修改指令,Convert將檔案指派表FAT和FAT32磁碟區轉換為NTFS檔案系統,而現有的檔案和資料夾完好無損,其語法是「convert [Volume] /fs:ntfs [/v] [/cvtarea:FileName] [/nosecurity] [/x]」。

PHP8.0中的資料庫連線庫:Doctrine PHP8.0中的資料庫連線庫:Doctrine May 14, 2023 am 09:00 AM

隨著PHP語言的發展,越來越多的開發者開始使用它來建立Web應用程式。使用PHP建立Web應用程式時,一個重要的部分是資料庫連接,儘管有許多資料庫連接庫可供選擇,但是Doctrine是其中一個備受推崇的庫。在本文中,我們將探討Doctrine在PHP8.0的應用。什麼是Doctrine? Doctrine是一個基於PHP的資料庫連接庫,它提供了一個物件導向

convert指令怎麼用 convert指令怎麼用 Oct 25, 2023 pm 02:55 PM

convert指令是ImageMagick影像處理軟體包中的一個命令列工具,用於影像格式轉換、影像處理和影像合成等操作。常見用法:1、簡單的圖片格式轉換:convert input.jpg output.png;2、調整圖片尺寸:convert input.jpg -resize 800x600 output.jpg;3、圖片裁切等等。

See all articles