简体   繁体   English

简单管理页面:Symfony2

[英]Simple Admin Page: Symfony2

I'm thinking of creating admin page with forms to modify, delete and add content to simple pages of website. 我正在考虑创建具有表单的管理页面,以修改,删除网站内容并将其添加到网站的简单页面。 What would you recommend me to approach this in Symfony2? 您会如何建议我在Symfony2中解决此问题?

Should I create new Bundle or just new Action in same controller where all the other pages are. 我应该在所有其他页面所在的同一控制器中创建新的Bundle还是仅创建新的Action。

I heard of this SonataAdmin , but I am not sure I need something this complicated. 我听说过这个SonataAdmin ,但是我不确定我是否需要这么复杂的东西。 My admin page will only contain few forms to modify some data that is stored on website. 我的管理页面将仅包含少量表格来修改存储在网站上的某些数据。 I don't need CMS functionality to create pages or posts. 我不需要CMS功能来创建页面或帖子。

All I want is simple, safe admin page and to know how nowadays this problem is solved. 我想要的是一个简单,安全的管理页面,并且知道如今如何解决此问题。

It looks like you really don't need SonataAdminBundle. 看来您真的不需要SonataAdminBundle。 It's huge and sometime difficult to understand. 它巨大且有时难以理解。 So, for such functionality you can create some secured area in your routing and use to access management pages. 因此,对于此类功能,您可以在路由中创建一些安全区域并用于访问管理页面。 Or you can implement simple authentication with hardcoded (inside config files) credentials (look detailed description here: http://symfony.com/doc/current/book/security.html ) and show for authenticated user additional elements on the pages (forms, buttons, etc.). 或者,您也可以使用硬编码的(内部配置文件)凭据来实现简单的身份验证(在此处查看详细说明: http : //symfony.com/doc/current/book/security.html ),并在页面上显示供身份验证的用户使用的其他元素(窗体,按钮等)。 It really depends on your wishes. 这真的取决于您的意愿。 I think you have to overthink all you have and just decide which way is more convenient for you. 我认为您必须考虑所有问题,然后决定哪种方法更方便。

Just create something like a AdminBundle and create your forms there. 只需创建一个AdminBundle之类的东西,然后在其中创建表单即可。 Secure your routes so that you need to login to acces that routes. 保护您的路由,以便您需要登录以访问该路由。

SonataAdmin is to much for this kind of work. SonataAdmin对于此类工作非常有用。

Example of a secured function where you need to be logged in as admin : 需要以admin身份登录的安全功能示例:

 /**
 * @Route("/", name="homepage", name="homepage")
 * @Route("/{_locale}", name="homepage", name="homepage")
 * @Security("has_role('ROLE_ADMIN')")
 * @Template("ProdacomMainBundle:Main:index.html.twig")
 */
public function indexAction() {
    return array();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM