spacer
Web Development Tutorials PHP Tutorials
 Developer Newsletter

Tutorials
AJAX
ASP
CGI & Perl
CSS
Flash
HTML
Illustrator
Java
JavaScript
Linux
MySQL
PHP
Photoshop
Python
Wireless
XML
Miscellaneous


Scripts Directory
AJAX Scripts
ASP Scripts
ASP.NET Scripts
CGI & Perl Scripts
Flash Scripts
Java Scripts
JavaScript Scripts
PHP Scripts
Python Scripts
Remotely Hosted Scripts
Tools & Utilities Scripts
XML Scripts

Web Hosting Directory
ASP.NET
Budget
Dedicated Servers
Ecommerce
Linux
Resellers
Shared
Small Business
Windows

Developer Manuals
Learn HTML
Learn PHP
Learn CSS
Learn AJAX
Learn JavaScript
Learn Pear
Free White Papers

Developer Resources
Developer Tools
Developer Content
Survey Software
Dedicated Servers




Rapid Application Development with CodeIgniter

By Akash Mehta
2008-02-17


MVC 101

In a framework-less PHP application, you'll typically have a number of seperate PHP scripts, each of which is accessed directly by the client. There might be a global header and footer, possibly with some standard functionality for database access. There are a number of problems with this approach, however, including inconsistent application entry points, repetition of code for standard tasks and so on. As the application grows, it can also become very inconsistent and hard to maintain.

The MVC design pattern goes a long way towards solving this. In MVC, your application is split into three parts - the Model, the View and the Controller. The Controller controls application flow and routing, handing off requests to other parts of the application. The Model manages data related to your application. Finally, the View represents the interface to your application, in this case our HTML front-ends. Views can contain basic logic, but most complex routines lie in the model.

The one problem with MVC, however, is that all this clean seperation is only effective if you observe it. You should start with the basic purpose of each section. For example, never access the database in your controller or view - that's what the model is for. Never output HTML in your controller or model, leave it to the view; and certainly never handle redirects within your view.

Still, here's what you should do. Your views can (and probably should) contain basic loops and simple if logic. Views should be where output is constructed, with only the bare essential data passed to them. Controllers can (and should) be full of all the business logic your application needs, and models should process data as needed without worrying about output. Keep this in mind and you should get a lot out of using MVC for your application.



Tutorial Pages:
» Why should you be using CodeIgniter?
» MVC 101
» Introducing CodeIgniter!
» Getting our feet wet
» Further CodeIgniter


Related Tutorials:
» Web Database Access from Desktop Applications
» CubeCart 3.0 Installation and Configuration
» PHP Site Search Made Easy
» Installing and Configuring Drupal 6.1
» Desktop Application Development with PHP-GTK
» Installing PHP on Windows



About the NetVisits, Inc Network | Write For Us | Advertise
Copyright ©2007 NetVisits, Inc Network. All Rights Reserved. Privacy Policy.
Visit other NetVisits, Inc. sites: