我正在开发一个Symfony2应用程序。我希望后端只能从内部网获得,前端可供公众使用。教义实体由两者共享。
最好的方法是什么?
最好的方法是使用 FOSUserBundle ( https://github.com/FriendsOfSymfony/FOSUserBundle ),并为后端确定哪些角色已授予对后端的访问权限。
例如:
frontend : no role defined
intranet : only registred user -> ROLE_USER
backend : only registred user with admin access -> ROLE_ADMIN
它非常容易部署,因为Symfony2文档谈到了它。
http://symfony.com/doc/current/cookbook/bundles/inheritance.html
还有一个非常好的SF2管理生成器:https://github.com/sonata-project/SonataAdminBundle
希望这会有所帮助