Quantcast
Channel: Freelance PHP Developer | PHP Freelancer » blogs
Viewing all articles
Browse latest Browse all 10

What is MVC ?

$
0
0

Model View Controller MVC

MVC is a design pattern. A Design pattern is a code structure that allows for common coding frameworks to be replicated quickly. You might think of a design pattern as a skeleton or framework on which your application will be built.

In the MVC framework that is created in this tutorial, several key points will be raised. The first is the frameworks needs a single point of entry, ie: index.php. This is where all access to the site must be controlled from. To ensure that a single point of entry is maintained, htaccess can be utilized to ensure no other file may be accessed, and that we hide the index.php file in the url. Thus creating SEO and user friendly URL’s.

It is beyond the scope of this tutorial to show how to set up htaccess and mod_rewrite and more information on these can be gained from the Apache manual. The .htaccess file itself looks like this.

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?rt=$1 [L,QSA]

The .htaccess file will permit access to the site via urls such as

http://www.example.com/news/show

If you do not have mod_rewrite available, the entry to the site will be the same, except that the URL will contain the values needed such as:

http://www.example.com/index.php?rt=news/show


Viewing all articles
Browse latest Browse all 10

Trending Articles