Why to use MVC ? its secured

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
manojsemwal1
Forum Contributor
Posts: 217
Joined: Mon Jun 29, 2009 4:13 am
Location: India

Why to use MVC ? its secured

Post by manojsemwal1 »

Hai i have done one of my php project in online collabritaion in education with 40 center. here i have used simple php code not typical. its working fine no problem. but i saw and reads most of the articals programmer are used MVC. i had read about mvc .but some are used zend framework some people are used cake php some are used zamp .
i have some query like
1- why we used MVC any security type problem in simple php code.?
2-which is the best framework in zend,cakephp or zamp.
3-Pl write more about MVC.


pl clear the doubt.

thanks.
Manoj
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Why to use MVC ? its secured

Post by Christopher »

MVC is a way to provide some clean separations in your code to promote reuse. You can create secure applications in PHP with or without MVC. For frameworks, they are all free so download and try them to see which best fits you.
(#10850)
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Why to use MVC ? its secured

Post by josh »

"Normal" top to bottom code is 1 tier. All code is in 1 file that gets run*.

* technically you could use includes but the idea is the HTML + logic is all mixed together.

Next level up is 2 tier is when you separate out the HTML out from the PHP code. This allows you to use different templates. Next level up is 3 tier where you have a Controller+Model. For example if you were a banking site your "Controller" would have actions like (deposit, withdraw). The "Model" would be the bank account itself, some sort of object, array or variable that represents how much money is in the account. The concept of the "transaction" is another Model. Models are implemented as objects, arrays, etc...

So 2 tier lets you use multiple templates with a single application. Or multiple applications running the same code all with different look + feel.

3 tier lets the programmer re-use code from "action" to "action". So if you have lots of "actions" in your application, you aren't copy & pasting code. That's really what it comes down to. It saves you a lot of copy & pasting. Copy & pasting is the root of all evil in programming because your code becomes bloated.
manojsemwal1
Forum Contributor
Posts: 217
Joined: Mon Jun 29, 2009 4:13 am
Location: India

Re: Why to use MVC ? its secured

Post by manojsemwal1 »

Thanks to give nice information. Which type of project we have to take in MVC style.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Why to use MVC ? its secured

Post by josh »

MVC will work on anything, a guestbook application for example. I suggest just sitting down and spending a weekend doing some tutorials. Google for "MVC tutorials".
manojsemwal1
Forum Contributor
Posts: 217
Joined: Mon Jun 29, 2009 4:13 am
Location: India

Re: Why to use MVC ? its secured

Post by manojsemwal1 »

Thanks
Ya i had tried to download but its give full and lengthy tutorial i need small tutorial so that i can easily understand if u have pl provide to me. in my mail id manojsemwal1@gmail.com

one more think i want to know in joomla and drupal etc. all are customization software in there developer are coded in bounded or not or he will work independently.

Thanks
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Why to use MVC ? its secured

Post by josh »

Here is a link to a tutorial. I don't understand the rest of what you're asking. http://framework.zend.com/manual/en/lea ... intro.html
Post Reply