ʎɹnɔɹǝW
ʎɹnɔɹǝW

Reputation: 881

How to group different functions of a bundle inside a symfony controller

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.

Upvotes: 0

Views: 92

Answers (1)

actarus
actarus

Reputation: 46

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

Upvotes: 1

Related Questions