symfony2のmapping.orm.ymlにつきまして

261 views
Skip to first unread message

hossy

unread,
Apr 20, 2013, 7:18:23 PM4/20/13
to symfony-...@googlegroups.com
度々すみません。
星です。

ブログチュートリアルを参考に開発を進めていますがスキーマファイルを生成する時に
php app/console generate:doctrine:entity --entity=MyBlogBundle:Post --format=annotation --fields="title:string(255) body:text createdAt:datetime updatedAt:datetime"
の様にテーブル毎でコマンドを打って作成する方法しかないのでしょうか?

また、スキーマファイルを一つにまとめたいと思っておりgoogleで検索そしていた所
下記のページに辿りつきました。
http://www.symfony.gr.jp/blog/20110506-symfony2-getting-easier-part-3

この方法を試してみたのですがうまくいきませんでした。

試したのは下記の方法です。

「app/config/config.yml」に下記を追加して

doctrine:
  orm:
    mappings:
      global:
        type:   yml
        dir:    %kernel.root_dir%/config
        prefix: Blog\Entity
「app/config/mapping.orm.yml」を追加し
「app/console doctrine:schema:update --force」のコマンドを打ちましたが何も起こりませんでした。
度々で申し訳ございません、お手数ではございますがご教授頂けると幸いです。

77web

unread,
Apr 20, 2013, 8:20:09 PM4/20/13
to symfony-...@googlegroups.com
菱田(@77web)です。

mapping.orm.ymlを書いた後、doctrine:schema:updateの前にdoctrine:generate:entitiesは実行していますか?

hossy

unread,
Apr 21, 2013, 10:15:20 PM4/21/13
to symfony-...@googlegroups.com
菱田 様

お返事ありがとう御座います。
行なった手順を書かせてもらいます。

1、「composer.phar create-project symfony/framework-standard-edition .」でプロジェクトを開始しました。
2、「app/config/parameters.yml」にDBの設定。
3、「app/console generate:bundle --namespace=App/DbBundle 」でバンドルの作成。
4、「app/config/config.yml」に下記を追加。
doctrine:
  orm:
    mappings:
      global:
        type:   yml
        dir:    %kernel.root_dir%/config
        prefix: App\DbBundle\Entity
※prerixの部分を理解出来ていません。

5、「app/config/mapping.orm.yml」を作成。

App\DbBundle\Entity\Test:
  type: entity
  table: test
  id:
    id:
      type: integer
      generator: { strategy: AUTO }
  fields:
     name:
       type: string
       length: 100
     price:
       type: decimal
       scale: 2
     description:
       type: text

6、「app/console doctrine:database:create 」データベース作成。
ここからの処理が凄く自分の中で曖昧です。
7、「app/console doctrine:generate:entities App/DbBundle/Entity --path=src/」
エラー:Namespace "App\DbBundle\Entity" does not contain any mapped entities. 

ここで止まっている状態です。
先ず最初に「app/console doctrine:generate:entity --entity="AppDbBundle:test"」等でentitiyを作成
してからでないといけないのでしょうか?

お手数では御座いますがご教授頂けると幸いです。

hossy

unread,
Apr 23, 2013, 10:01:14 PM4/23/13
to symfony-...@googlegroups.com
解決しました。

どうもです。



2013年4月21日日曜日 8時18分23秒 UTC+9 hossy:
Reply all
Reply to author
Forward
0 new messages