douhu8851 2017-01-25 10:05
浏览 11

如何在symfony控制器内对bundle的不同功能进行分组

I am new to Symfony, and I just installed it, I removed the default AppBundle and generated my own. Now, I am trying to create an application that aggregates some realstate data in shows it in my site, or in other words,

It will fetch from various realestate sites, apartments that are available for rent and display it.

The problem I have is not technical, but strategical.

As I do not know how to divide the various tasks of my app and group it in a way that makes sense.

To give you some insights, I have those urls in mind for now

/                          # index page
/about                     
/contact  
/login
/register
/subscribe                 # subscribe to a newsletter 
/search?q=..               # display search result
/announce/add              # add new apartment for rent
/announce/{id}/{slug}      # unique url for each anounce
/announce/{id}/{slug}/edit # edit announce if submitted by user

From this, I am thinking maybe I should map routes to controllers as:

/                          DefaultController::indexAction()
/about                     DefaultController::aboutAction()
/contact                   DefaultController::contactAction()

/login                     UserController::loginAction()
/register                  UserController::registerAction()

/subscribe                 UserController::subscribeAction()

/search?q=..               SearchController::searchAction()

/announce/add              AnnounceController::addAction()
/announce/{id}/{slug}      AnnounceController::showAction()
/announce/{id}/{slug}/edit AnnounceController::editAction()

So, this is all I can think of at the moment.

  • 写回答

1条回答 默认 最新

  • duanlu1950 2017-01-25 10:16
    关注

    First of all, be aware of the good pratice of symfony. It's recommended to use AppBundle as unique bundle. The choice of the controller you're gonna use is not so important from a technical view. It should be coherent in order to find your controller action easily

    You can find a lot of good pratices here : http://symfony.com/doc/current/best_practices/index.html

    评论

报告相同问题?

悬赏问题

  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据