 |
Account Login
|
 |
 |
Latest Articles
|
 |
 |
IRC Channel
|
 |
 |
Associates
|
 |
 |
Associates
|
 |
|
|
View Poll Results: How are you with MVC in PHP?
|
|
I am using framework which are in MVC
|
 
|
12 |
63.16% |
|
I do all my applications in MVC which is of my own
|
 
|
3 |
15.79% |
|
I never use MVC.
|
 
|
3 |
15.79% |
|
My applications are efficient without MVC
|
 
|
2 |
10.53% |
 |
 |
|
 |
11-22-2009, 04:23 AM
|
#1 (permalink)
|
|
The Visitor
Join Date: Nov 2009
Posts: 4
Thanks: 0
|
MVC approach in PHP Development
|
|
|
|
11-22-2009, 10:33 AM
|
#2 (permalink)
|
|
is cute and cuddly
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
|
Personally I like the Model Plane > View from my Patio > BBQ pattern.
|
|
|
|
11-22-2009, 12:05 PM
|
#3 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Quote:
Originally Posted by delayedinsanity
Personally I like the Model Plane > View from my Patio > BBQ pattern.
|
What is that?
__________________
|
|
|
|
11-22-2009, 05:51 PM
|
#4 (permalink)
|
|
The Addict
Join Date: Aug 2008
Posts: 336
Thanks: 8
|
delayedinsanity haha that sounds like a great model to follow
|
|
|
|
11-24-2009, 03:24 AM
|
#5 (permalink)
|
|
The Contributor
Join Date: Feb 2007
Posts: 64
Thanks: 9
|
About a month ago I had never touched anything MVC. My first time looking at it it just seemed like it over complicated everything. I decided to take a closer look and write my own basic little framework and now I understand it very well and really like using it. It might not be appropriate for everything, escpecially very small scripts, but I can definitely see myself using it more from now on.
|
|
|
|
11-24-2009, 03:36 AM
|
#6 (permalink)
|
|
is cute and cuddly
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
|
Using MVC to handle a form is like hitting up Wal-Mart in a Peterbilt.
If you're developing a major application however (delivering the goods to Wally World), then MVC is completely the opposite of over-complication. It's a very solid design pattern, usually being built through the use of other very popular design patterns, which I would presume accounts for a large portion of its popularity.
At the very least, if you plan on developing enterprise level applications, or even just programming (PHP or otherwise) for an extended period of time, it's one of the many patterns that should be learned just to gain the experience from it. The concept alone can turn some on-paper ideas from improbable to highly possible very quickly.
I still prefer BBQing though.
|
|
|
|
11-27-2009, 07:42 AM
|
#7 (permalink)
|
|
The Wanderer
Join Date: May 2009
Posts: 19
Thanks: 4
|
i use codeIgniter and really it simplifies all work incredibly !
__________________
I love you NASSER
|
|
|
|
11-27-2009, 09:19 AM
|
#8 (permalink)
|
|
The Prestige
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
|
MVC is great when used in the appropriate places. It can and will over complicate things if the problem has a relatively simple solution, akin to hammering a panel pin in with a sledgehammer, whilst it will probably do the job its completely unnecessary, when a smaller hammer would do it just fine (and will also minimize the risk of pulverizing the object in which the nail is going into)
I have found MVC to be fabulous in my work on a daily basis on medium to large projects.
I must say, I too prefer to BBQ, grr now i'm hungry again!
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
Last edited by sketchMedia : 11-27-2009 at 09:19 AM.
Reason: speelink
|
|
|
|
12-10-2009, 02:47 AM
|
#9 (permalink)
|
|
The Wanderer
Join Date: Dec 2008
Posts: 16
Thanks: 2
|
I have never used MVC as i have never got how it works.
also what this BBQ?
|
|
|
|
12-10-2009, 03:29 AM
|
#10 (permalink)
|
|
how quixotic are you?
Join Date: Dec 2007
Location: Lapeer, MI
Posts: 445
Thanks: 37
|
Basically it's like this:
- Different controllers (or methods in controller classes) represent different pages
- Controllers use models to interact with the database
- Controllers use views to display HTML to the user
It just divides your application into parts based on primary function. Makes it a lot more organized and speeds development.
|
|
|
|
12-10-2009, 01:18 PM
|
#11 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Quote:
Originally Posted by ETbyrne
- Controllers use models to interact with the database
|
Not really. They don't need to use models to interact with the database. Otherwise you wouldn't be able to access the database from the controllers. Besides, models can be used for a number of other things, not only database handling.
However, models are most often used to interact with the database. It's just not limited to it.
__________________
|
|
|
|
12-10-2009, 04:48 PM
|
#12 (permalink)
|
|
The Prestige
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
|
Quote:
Originally Posted by Tanax
Otherwise you wouldn't be able to access the database from the controllers.
|
Now why would you need access to the DB via the controller?
In my mind controllers should not do any form of business logic, all of that is handled via the model, just like views handle presentation logic, so therefore you shouldn't need to access the DB via the controller. Obviously there is a need for a certain amount of logic in controllers, as there is in the view layer (don't get me started on PHP template languages at this stage of the day PLEASE), but to have the controller layer bunged up with logic is just silly, you may as well just go back to the old skool way and have a php file per page.
Models are not synonymous with database. I quite often see code that is supposedly 'MVC' and all I can see in the model is a pointless 'ActiveRecord' (or similar) class with no logic in it and a controller littered with business logic.
Controllers are there to glue the model to the view, interpreting user input into the model and passing data back to the user via the view.
fat model and a thin controller is all you need to remember.
I'll stop myself there as we are wandering dangerously close to the 'off topic' mark and I will being ranting before long.
Now where did I put my coffee?
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
|
|
|
|
12-10-2009, 08:21 PM
|
#13 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Quote:
Originally Posted by sketchMedia
Now why would you need access to the DB via the controller?
Now where did I put my coffee?
|
You should probably have taken your coffee before replying xD
I didn't say you should access the database via the controller. I just said you CAN, and that the use of models isn't limited to database handling.
I "proved" this by saying that otherwise you wouldn't be able to access the database via the controller. Because if models would be limited to database handling, then you should be forced to use models for the database handling, and controllers wouldn't allow you to access the database. But controllers do allow this thus models aren't limited to database handling.
__________________
|
|
|
|
12-10-2009, 08:51 PM
|
#14 (permalink)
|
|
how quixotic are you?
Join Date: Dec 2007
Location: Lapeer, MI
Posts: 445
Thanks: 37
|
You both make valid points, but keep in mind I was just generalizing for the sake of simplicity. Also remember that there are different variations of MVC, but again, that just makes it all the more complicated for someone trying to learn it at first. :)
|
|
|
|
12-10-2009, 09:21 PM
|
#15 (permalink)
|
|
The Prestige
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
|
Quote:
Originally Posted by Tanax
You should probably have taken your coffee before replying xD
I didn't say you should access the database via the controller. I just said you CAN, and that the use of models isn't limited to database handling.
I "proved" this by saying that otherwise you wouldn't be able to access the database via the controller. Because if models would be limited to database handling, then you should be forced to use models for the database handling, and controllers wouldn't allow you to access the database. But controllers do allow this thus models aren't limited to database handling.
|
Yea, its not a good idea me replying to threads after just comming out of a meeting and a lack of coffee, I'll remember that in the future! I still maintain that the idea of accessing the DB from the controller makes me feel a little edgy, it will end up in a crawling horror of an application!
Quote:
|
Originally Posted by ETByrne
You both make valid points, but keep in mind I was just generalizing for the sake of simplicity. Also remember that there are different variations of MVC, but again, that just makes it all the more complicated for someone trying to learn it at first. :)
|
Indeed! Its probably one of the hardest patterns to learn because it is interpreted by many people in many different ways. The way I do it is the way I found it most useful for my own projects, I found that lumping most of the logic in models made it alot easier for me in a number of ways (reuse, unit testing etc).
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
|
|
|
|
12-26-2009, 05:45 AM
|
#16 (permalink)
|
|
The Wanderer
Join Date: Aug 2009
Posts: 18
Thanks: 1
|
I dont even know what MVC stands for haha.
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|