Home arrow PHP arrow Completing an MVC-Based Framework's Controller Class

Completing an MVC-Based Framework's Controller Class

In this twelfth part of the series I finish building the controller class that permits you to run CRUD operations against the pertinent ďusersĒ MySQL table. This class uses the model to interface with the data layer, the input class to filter incoming data, and the view class to display output on the browser. This process demonstrates the real functionality of the MVC framework developed in previous tutorials.

  1. Completing an MVC-Based Framework's Controller Class
  2. Managing users via a controller class
  3. Saving and deleting user records
  4. The finished version of the user controller class
By: Alejandro Gervasio
Rating: starstarstarstarstar / 1
July 06, 2010

print this article



Any PHP coder who wants to build thorough, scalable web applications must understand how to implement certain design patterns. This doesnít mean that mastering these patterns will guarantee writing bullet-proof code that scales well in different contexts. But, as the web continues to evolve, design patterns can be of great of help in tackling the challenges imposed by modern web development.

One pattern that has rapidly gained popularity with web developers is called Model-View-Controller. It allows developers to create programs that maintain their business and application logic partially separated from their visual presentation.

It's worth mentioning that the MVC pattern has come into widespread use in frameworks, including those built in PHP. Kohana, CodeIgniter and CakePHP are good examples of frameworks that rely on an MVC layer to leverage all of its functionality. However, you as a PHP programmer may want to learn how to build your own MVC-based framework, or simply have a better understanding of how the existing ones work under the hood.

If thatís the case, then in this series of tutorials youíll find a friendly guide that will walk you through the development of a basic framework in PHP 5. This framework will use a set of reusable components that can be easily glued together under a strict MVC schema.

Now that you know what to expect from this group of tutorials, itís time to review the concepts that were deployed in the last one. In that installment of the series I demonstrated how easy it is to create a MySQL-driven application by using some of the classes of the sample framework built previously, since I defined a basic controller class that could fetch records from a table containing user-related data, as well as create new records and update others.

It's valid to point out, though, that some methods of the controller embedded data retrieved via the model into a few view files. These view files havenít been defined yet. Thus, in the lines to follow Iím going to add to the controller a method that will permit the deletion of database rows.

Ready to learn more on this topic? Then, letís get started!

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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- 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: