Home arrow PHP arrow Adding a Controller Class to an MVC-Based Framework in PHP 5

Adding a Controller Class to an MVC-Based Framework in PHP 5

In this tenth part of the series, I start building a basic MySQL-driven application whose main tasks consist of selecting, inserting, updating and deleting records on some hypothetical users by means of the framework we've built.

TABLE OF CONTENTS:
  1. Adding a Controller Class to an MVC-Based Framework in PHP 5
  2. Using the MVC framework: setting up the database schema and building a controller class
  3. Implementing the controller's index() method
  4. The partial source code of the user controller class
By: Alejandro Gervasio
Rating: starstarstarstarstar / 2
June 29, 2010

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

As you know, in the last few years the proliferation of PHP frameworks on the web has been so rapid and vast that now a PHP developer has a plethora of options to choose from. 

While some frameworks that are more popular than others, all of them try to make PHP programmers' lives much easier by providing them with a set of reusable components that can vastly speed up the development of modern web applications.

With the variety of frameworks available nowadays, you've probably already started using one that implements the Model-View-Controller design pattern, such as Zend, Kohana or CodeIgniter, to name just a few. However, it's possible that you may want to build your own MVC-driven framework, or acquire a more solid understanding of how the existing ones function internally.

If that's the case, then in this group of tutorials you'll find a guide that will show you in a step-by-step fashion how to build a simple framework in PHP 5 that will stick to the architecture imposed by the Model-View-Controller design pattern.

And now that you've been introduced to the subject of this article series, it's time to review the topics covered in the last part. In that part of the series I added another core component to the framework being developed -- a model class whose main task was handling, via a simple API, the framework's data layer, composed of one or more MySQL tables.

True to form, the stack of libraries created so far allow you to implement the "M" and "V" sections of the MVC pattern, which are the Model and View layers respectively. So, what's the missing part of this schema? Yes, you guessed right! It's necessary to build a controller class that glues these two pieces together.

Thus, in the lines to come I'm going to start building a basic MySQL-driven application that will use not only a controller class, but all of the framework's previously-created components. Let's begin.



 
 
>>> More PHP Articles          >>> More By Alejandro Gervasio
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: