Porting functional code to MVC structure

Discussion for various published PHP frameworks, including Zend Framework, CodeIgniter, Kohana, CakePHP, Yii, Symfony, and others.

Moderator: General Moderators

Post Reply
Live24x7
Forum Contributor
Posts: 194
Joined: Sat Nov 19, 2011 9:32 am

Porting functional code to MVC structure

Post by Live24x7 »

I am learning MVC framework(CI & YII for now)

Towards this i am trying to port an existing application which was done the functional way to MVC framework (say for example to CI)

Here's what I have thought about it:

1) For every database table I will create a fresh model class
2) then take up each php page like login.php, register.php, member.php etc and break it into two components for the view & controller.

Anything else that is important to keep in mind ?
Actually i have a gut feeling that there's more to the controller design than this.
How to decide the number of controllers required?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Porting functional code to MVC structure

Post by Christopher »

Live24x7 wrote:1) For every database table I will create a fresh model class
A Model is not always just a Gateway to a database table. A Model is an Entity in the Domain of the problem that the web application solves.
Live24x7 wrote:2) then take up each php page like login.php, register.php, member.php etc and break it into two components for the view & controller.

Anything else that is important to keep in mind ?
Actually i have a gut feeling that there's more to the controller design than this.
How to decide the number of controllers required?
A Controller deals with one or more associated request, and controls the program flow for those requests. So you could have login and register Controllers, or you could have a user Controller with login and register actions. It often makes sense to group related requests.
(#10850)
Live24x7
Forum Contributor
Posts: 194
Joined: Sat Nov 19, 2011 9:32 am

Re: Porting functional code to MVC structure

Post by Live24x7 »

Christopher wrote:A Model is not always just a Gateway to a database table. A Model is an Entity in the Domain of the problem that the web application solves.
Thanks will keep that in mind as the acid test for every model design.
It often makes sense to group related requests.
That is great..definitely helpful
Post Reply