3

I'd like to build a mid-sized website which also includes a mobile website and an API. As I already have some experience with Symfony I'd like to build the project on top of it.

However, I have no idea how to structure my project. Maybe there are some guidelines how to approach this problem?

Is it a good idea to build a each component as an individual Bundle? E.g. CoreBundle, APIBundle, WebsiteBundle and MobileWebsiteBundle, whereas CoreBundle would contain all Models and Validation and the other Bundles Controllers and Views?

Or is there a completely other way?

4

1 に答える 1

2

すべてのコードをバンドルに入れる必要はありません。実際、そこに置くコードが多いほど、それをフレームワークに結合することになります。

Symfony に関連しないコードの一部を別の名前空間に抽出し、バンドルを PHP コードと Symfony フレームワークの間の接着剤のように扱うことを検討してください。

例えば:

  • アクメ
    • バンドル
      • APIバンドル
      • ウェブサイトバンドル
    • 実在物
    • ツール
    • 小枝

バンドルの外にエンティティを配置する場合は、app/config/config.ymlで新しいマッピングを構成する必要があります。

doctrine:
    orm:
        mappings:
            Bossa:
                type:       annotation
                is_bundle:  false
                dir:        %kernel.root_dir%/../src/Acme/Entity
                prefix:     Acme\Entity\
                alias:      Acme
于 2012-12-30T13:41:04.280 に答える