This is not the document you are looking for? Use the search form below to find more!

Report home > Computer / Internet

Beginners Guide to Php Development with MVC Architecture

3.75 (4 votes)
Document Description
eTatvasoft has a full understanding in using the Model-View-Controller (MVC) architecture for developing websites and web applications using PHP. Our PHP developers have a rich experience and solid expertise of working with PHP frameworks like Zend, CakePHP, and CodeIgniter that have the MVC architecture support. PHP web development with MVC architecture allows us to create dynamic webpages that provide fast interactions with the users.
File Details
Submitter
Embed Code:

Add New Comment




Showing 2 comments

by siraj k on July 09th, 2010 at 01:36 am
usefull........
by neha rai on December 21st, 2010 at 06:41 am
Auberge Signature Modular Homes - Green, Energy Efficient and Economical, Log Homes, Minimalistic Homes, English Homes, Tree Houses
Description
Place your Query online to select a home, Log Home in India, Minimalistic Home in India, English Home in India, Tree Houses in India, Bangalore, Pune, Delhi, Kolkata, Hyderabad and other places in India, We will give you the best price and Service.
Key word--
MODULAR HOMES,Architect, Interior, Log Home, Minimalistic Home, English Home, Tree Houses, Woodward Villa, Mayfair Cottage, Sterling Villa, Red House, Rose Villa, Sunnyside Villa, Sunny Brook Villa, Olive Villa, Spring field Cottage, Fern Villa, Svelte, Kallisto, View, Carlton Woods , Knights Wood, Whispering Pine, Pine Cove, Knotty Pine, Falcon Crest, Pine Ridge, Log Home in India, Minimalistic Home in India, English Home in India, Tree Houses in India, Bangalore, Pune, Delhi, Kolkata, Hyderabad and other places in India, We will give you the best price and Service.
modern homes,prefabricated homes,prefab homes,prefab houses,log cabins,log homes,log tree house,log home floor plans,english homes floor plan,minimalist floor plan,log tree house,
Related Documents

Beginners guide to php development with mvc architecture

by: marcin, 9 pages

Beginner’s Guide to PHP Development with MVC Architecture Version 1. 0 Publis hed 8 May 2010 Table of Contents Beginner’s ...

PHP Web Development with MVC Architecture

by: etatva, 9 pages

eTatvasoft has a full understanding in using the Model-View-Controller (MVC) architecture for developing websites and web applications using PHP. Our PHP developers have a rich experience and solid ...

SPIRIT OF BALI TOUR: BEGINNERS GUIDE TO BALINESE PRAYER, OFFERINGS, TEMPLES AND RELIGIOUS CEREMONIES

by: hanbal, 12 pages

BEGINNERS GUIDE TO BALINESE PRAYER, OFFERINGS, TEMPLES AND RELIGIOUS CEREMONIES

A Beginners Guide to Dual-Quaternions: What They Are, How They Work, and How to Use Them for 3D Character Hierarchies

by: johnsimpson, 10 pages

In this paper, we give a beginners guide to the practicality of using dual-quaternions to represent the rotations and translations in character-based hierarchies. Quaternions have proven themselves ...

6) robotica mcgraw - hill - pic robotics a beginners guide to robotics projects using the pic micro(2)

by: csenger, 290 pages

6) robotica mcgraw - hill - pic robotics a beginners guide to robotics projects using the pic micro(2)

Beginners Guide To Logical Framework Approach (BOND)

by: nayu, 8 pages

Beginners Guide To Logical Framework Approach (BOND)

A Beginners Guide To Internet Marketing

by: richardjagger, 19 pages

In A Beginners Guide To Internet Marketing, Here Are Some Of The Things That You'll Discover ... The Top 5 Ways To make Money Online Affiliate Programs - How to get The Click The Top 5 Ways To ...

The Beginner's Guide to Debating

by: juniordebating, 4 pages

The title says it all

A Beginners Guide To Piano & Keyboard

by: asapiano, 3 pages

A very easy to follow guide to piano and keyboard covering all the essentials for a beginner.

Offshore PHP Development - An opportunity Too Good To be Missed

by: aaptijoshi, 2 pages

Offshore PHP development has emerged as one of the most favorite choice of organizations who seek high quality web solutions for their myriad business requirements. India's booming IT industries have ...

Content Preview
Beginner’s Guide to PHP Development with
MVC Architecture
Version 1. 0 Publis hed 8 May 2010


Table of Contents
Beginner’s Guide for PHP Development with MVC Architecture .............................................................. 1
MVC Architecture Part 1: Introduction to the Architecture ...................................................................... 2
MVC Architecture Part 2: Understanding the Interiors ............................................................................. 4
Example of MVC .................................................................................................................................. 4
Model Directory .................................................................................................................................. 5
Files in the model directory ................................................................................................................. 5
Template Directory .......................................................................................................................... 5
Controller Directory ......................................................................................................................... 6
.htaccess file .................................................................................................................................... 6
Index.php ........................................................................................................................................ 7
MVC Architecture Part 3: Creating a New Page in MVC Architecture........................................................ 7
Login.tpl.php.................................................................................................................................... 8







Beginner’s Guide to PHP Development with MVC Architecture
MVC Architecture Part 1: Introduction to the Architecture

Web development in PHP introduces a powerful architecture for PHP frameworks like Zend, CodeIgniter,
and CakePHP – Model-View-Controller (MVC). MVC is more than it meets the eye. It is not just any other
web development framework architecture for building elegant and systematic websites, but it has a full
capability to support rapid web application development and dynamic interactivity with the database as
well. You may find numerous articles on this subject over the Internet and some of them will tell a tale
of comprehensive exclusivity as well. This is not a topic to be discussed in one article. A wide prospect
such as MVC architecture should be dedicated more articles to elaborate on the complexity of the
architecture. Here we try to cover maximum ground as much possible in three parts – the first post shall
introduce and talk a wee bit on the MVC architecture, the following will delve deeper and explain the
interiors of MVC, and the last article is a tutorial type on creating a website using MVC architecture.
MVC methodology typically splits the architecture of the website into 3 distinct parts which are kept
operationally separate but interact with each other to deliver all aspects of the website and the
administration system. The main aim of the MVC architecture is to separate the business logic and
application data from the presentation data to the user. Adhering to MVC architecture benefits you in
attaining a perfect design for an enterprise web application.



eTatvasoft - PHP Development Company

Page 2 of 9


Beginner’s Guide to PHP Development with MVC Architecture
There is a common control flow in all forms of MVC built web applications. The Controller lies at the
core of the architecture and it interacts with the user through the web browser. Behind the scene it
communicates with the Model and the View components of the architecture.
The Model actually envelops the database so that the Controller can notify and direct the database of
the user actions on the browser. It is here that the database is modifies in accordance with the requests
submitted by the user. This improves user interactivity and hence the overall seamless experience.
On receiving the query request from the user the controller handles the Model and in return Model
notifies View to update the user interface (UI) on the screen in accordance to the database change.
When the user enters another query, the cycle is restarted.


















eTatvasoft - PHP Development Company

Page 3 of 9


Beginner’s Guide to PHP Development with MVC Architecture
MVC Architecture Part 2: Understanding the Interiors

In the previous post we learnt what MVC actually is and how does it work. In this post we shall elaborate
our discussion on the interiors of the MVC architecture. To understand the architecture we first suppose
and example of a typical website built on the MVC architecture. The following picture gives an idea of
the directory structure of the website and so to understand the architecture, we shall understand the
structure of mentioned here.
Example of MVC

Now, any web developer will know what the index.php and the .htaccess files are for, though we shall
mention them in our explanation a little later. But the point here is what are the other folders viz. lib,
templates, and websites for? Well, these are the MVC folders, and they are labeled according to their
roles in the architecture. We shall start from the left most label and continue on to their right ones.






eTatvasoft - PHP Development Company

Page 4 of 9


Beginner’s Guide to PHP Development with MVC Architecture
Model Directory

The Model is where business logic is stored. Business logic is loosely defined as database connections or
connections to data sources, and provides the data to the controller. The Model object knows about all
the data that need to be displayed. It is Model who is aware about all the operations that can be applied
to transform that object. It only represents the data of an application. The Model represents enterprise
data and the business rules that govern access to and updates of this data. Model is not aware about the
presentation data and how the data will be display to the browser.

Files in the model directory:
class.pagging.php - Model for managing pagging of the whole site.
class.session.php - Model that is used for managing session of whole site.
common.functions.php - Model that is used for managing common function of the whole site.
ctrl.class.php - Controller that is used for communication between the template and the Model file
db.class.php - Model that is used for Database connection, insert, update, and delete functionality.
tpl.class.php - Model that is used to display template file.

Template Directory

The View contains code that relates to presentation and presentation logic such as templating
and caching. The View represents the presentation of the application. The View object refers to
the model. It uses the query methods of the Model to obtain the contents and renders it. The
View is not dependent on the application logic. It remains same if there is any modification in
the business logic. In other words, we can say that it is the responsibility of the View's to
maintain the consistency in its presentation when the Model changes.
eTatvasoft - PHP Development Company

Page 5 of 9


Beginner’s Guide to PHP Development with MVC Architecture
Controller Directory

Controller is often referred to as the application layer of the website. The Controller component is
basically the code that processes data, writes out pages, gets data, logs, creates events and so on.
Essentially this is the active part of the site & system which interface between the database, assets,
templates et al, generating a result which the end user can see. Whenever the user sends a request for
something then it always go through the Controller. The Controller is responsible for intercepting the
requests from View and passes it to the model for the appropriate action. After the action has been
taken on the data, the Controller is responsible for directing the appropriate View to the user

.htaccess file


This is how a typical .htaccess file is written. The generic names such as “REQUEST_FILENAME” should
be replaced by the respective names for your website.





eTatvasoft - PHP Development Company

Page 6 of 9


Beginner’s Guide to PHP Development with MVC Architecture
Index.php


In the index.php file first we set the path variable. Include config.inc.php file. The first config.inc.php file
is global configuration file and second one is site configuration file if we have multiple site then we
require to use this two configuration files lest we only include first configuration file.
On line no 15 we check the authentication for particular user.
On line no 16 we check the page access for particular user and anonymous user.
Define “REQUEST_PAGE” and “_REQUEST_LANG_ID” (Use for Multilanguage)
Load Controller and Tpl file using load function.



MVC Architecture Part 3: Creating a New Page in MVC Architecture

eTatvasoft - PHP Development Company

Page 7 of 9


Beginner’s Guide to PHP Development with MVC Architecture
To create a new page in MVC architecture we need to create two new files - one file in template
directory and other file in controller directory.
Please check the below example
We first create one .tpl file in template directory named loginl.tpl.php and put the below code in that
file.
Login.tpl.php














eTatvasoft - PHP Development Company

Page 8 of 9


Beginner’s Guide to PHP Development with MVC Architecture
Secondly, we put one .php file in the Controller file and put the below code into that file.


And thus you get your first MVC architecture website. So now you can use your new website by typing
the URL of your website and accessing it from a web browser.

eTatvasoft - PHP Development Company

Page 9 of 9


Download
Beginners Guide to Php Development with MVC Architecture

 

 

Your download will begin in a moment.
If it doesn't, click here to try again.

Share Beginners Guide to Php Development with MVC Architecture to:

Insert your wordpress URL:

example:

http://myblog.wordpress.com/
or
http://myblog.com/

Share Beginners Guide to Php Development with MVC Architecture as:

From:

To:

Share Beginners Guide to Php Development with MVC Architecture.

Enter two words as shown below. If you cannot read the words, click the refresh icon.

loading

Share Beginners Guide to Php Development with MVC Architecture as:

Copy html code above and paste to your web page.

loading