我对Symfony2项目的架构有疑问。
是否有任何特定的方式来拥有这样一个项目的架构:
/app
/src
--/Admin
----/DefaultBundle
------/Controller
------/DependencdyInjection
------/Entity
------/Form
------/Resources
------/...
--/Front
----/DefaultBundle
------/Controller
------/DependencdyInjection
------/Entity
------/Form
------/Resources
------/...
/vendor
/www
并为两个模块使用一个Entity类(Admin / Front)?
答案 0 :(得分:2)
Symfony2遵循这一惯例:
/src/OrganizationName/SomeBundle/Controller [Entity / Resource / etc. ]
所以你应该提供2个捆绑包[例如公共FrontendBundle
文件夹中的AdminBundle
,YourAwesomeOrganization
]。
然后你可以照常在两者之间分享课程,例如:
<?php
use YourAwesomeOrganization\FrontendBundle\Entity\User;
use YourAwesomeOrganization\BackendBundle\Form\Type\LoginFormType;
答案 1 :(得分:0)
Ofcourse。只需像创建其他任何内容一样创建这些包,并在AppKernel
中启用它们。
答案 2 :(得分:-1)
我在使用Sf2 / Zf2的工作过程中理解的是你可以/必须使用的东西
&#34;服务经理&#34;用于在捆绑/模块之间共享不同的功能:
Sf2:http://symfony.com/doc/current/book/service_container.html
Zf2:http://framework.zend.com/manual/2.0/en/modules/zend.service-manager.intro.html