Pro PHP MVC (Expert's Voice in Open Source)

Pro PHP MVC (Expert's Voice in Open Source)

Chris Pitt

Language: English

Pages: 500

ISBN: 1430241640

Format: PDF / Kindle (mobi) / ePub


Model View Controller (MVC) is becoming the definitive architecture of website development frameworks due to the stability, extensibility and predictability it lends to development. It is not just the primary separation of database, business logic and interface components, but includes a wide range of considerations for building high-performing, scalable and secure applications.

Deciding which MVC framework best suits the project you are about to begin is one of the biggest challenges you'll face as a developer. If you are part of a team, this decision has probably already been made for you; but in any event, you'll need to know how (and why) the framework authors made it work the way it does.

Pro PHP MVC looks at the building blocks that make any good MVC framework, and how they apply to PHP. It exposes all considerations that many developers take for granted when using a popular framework, and teaches you how to make the framework your own. 

Over the course of reading this book, you will learn the theoretical implications of the choices you would make when writing your own MVC framework, and how to put the pieces together in a cohesive package. We take a look at the highly modular Zend Framework―how to use its collection of loosely coupled classes to build a unified system. We also look at CakePHP, learning from its automated build system (Bakery) and highly intuitive approach to rapid development. This book will lay bare all the secret parts of MVC for you.

Designing Games: A Guide to Engineering Experiences

Linux System Programming: Talking Directly to the Kernel and C Library

Beginning SQL Server 2012 for Developers

Ruby and MongoDB Web Development Beginner's Guide

Computer Architecture: A Quantitative Approach (4th Edition)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

$reflection = new \ReflectionProperty($this->_class, $property); return $reflection->getDocComment(); } protected function _getMethodComment($method) { $reflection = new \ReflectionMethod($this->_class, $method); return $reflection->getDocComment(); } } } The first few methods of our Inspector class use built-in PHP reflection classes to get the string values of Doc Comments, and to get a list of the properties and methods of a class. If we only wanted the string values, we could make

function first($where) { $user = new User(); // get the first user $user->db->where($where); $user->db->limit(1); $query = $user->db->get("user"); // initialze the data $data = $query->row(); $user->_populate($data); // return the user return $user; } public static function count($where) { $user = new User(); $user->db->where($where); return $user->db->count_all_results("user"); } public static function all($where = null, $fields = null, $order = null, $direction =

$stringLength = new Zend_Validate_StringLength(array("min" => 0, "max" => 255)); if (empty($email) || !$stringLength->isValid($email)) { $valid = false; $errors["email"] = "Email field required"; } if (empty($password) || !$stringLength->isValid($password)) { $valid = false; $errors["password"] = "Password field required"; } // if form data passes validation... if ($valid) { $user = Application_Model_User::first(array( "email = ?" => $email, "password = ?" => $password ));

needs to handle multiple defined routes and inferred routes if no defined routes are matched. This is demonstrated in Listing 7-6. Listing 7-6. Route Management Methods namespace Framework { use Framework\Base as Base; use Framework\Registry as Registry; use Framework\Inspector as Inspector; use Framework\Router\Exception as Exception; class Router extends Base { /** * @readwrite */ protected $_url; /** * @readwrite */ protected $_extension; /** * @read */ protected

friend/unfriend actions, so we will use this opportunity to shorten many of the URLs we have already seen, as shown in Listing 17-6. Listing 17-6. public/routes.php // define routes $routes = array( array( "pattern" => "register", "controller" => "users", "action" => "register" ), array( "pattern" => "login", "controller" => "users", "action" => "login" ), array( "pattern" => "logout", "controller" => "users", "action" => "logout" ), array( "pattern" => "search",

Download sample

Download