Doctrine248 コマンドラインツールは yml/xml/entities を生成します

WBOY
リリース: 2016-07-29 08:58:19
オリジナル
1032 人が閲覧しました

Doctrine2 圧縮パッケージの 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);
ログイン後にコピー

上記はヘルプであり、ここに例があります

/var/www/doctrine$ php vendor/bin/doctrine orm:convert-mapping xml config/xml/ --from-database
ログイン後にコピー

まず、Linux で実行するコマンドを示します。 cd に の下 /var/www/doctrine (一部の新人は、cd とは何ですか、なぜこのディレクトリがあるのか​​と尋ねました ~~cd とは何ですか、さようなら、この種の質問については Baidu にアクセスしてください。なぜこのディレクトリがあるのですか、これはプロジェクトです)フォルダー、つまり、以下に doctrine パッケージがあります)。前のコマンドでは説明を省略しています。説明の後ろにある「xml」は生成されるファイルの種類を意味し、「config/xml/」は XML 格納ディレクトリを意味し、--from-database はデータベースから生成されることを意味します。

2. yml を生成し、エンティティを生成します

/var/www/doctrine$ php vendor/bin/doctrine orm:generate-entities src/ --regenerate-entities
ログイン後にコピー

これは単純にテスト用です。変更された では、最初に yml を生成してからエンティティを生成する必要があります。とにかく、操作に問題があるのでしょうか。

一般的に使用されていないため、PHP ORM に関する記事が少なすぎます。はっきり言って、PHP ORM はあまり役に立たず、純粋に便利です

上記では、yml/xml/entities を生成するための Doctrine248 コマンド ライン ツールを、関連するコンテンツも含めて紹介しています。PHP チュートリアルに興味のある友人に役立つことを願っています。

関連ラベル:
ソース:php.cn
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!