zend framework design patterns, profiling

10
PHP Design Patterns and Profiling – supported by the Zend Framework Martin Buchmayr Supervisor: Michael Ulm

Upload: martin-buchmayr

Post on 25-Dec-2014

3.169 views

Category:

Technology


0 download

DESCRIPTION

[Welcome] Hello and welcome everyone to my project work presentation. My project is about design patterns and profiling by examining a web application created with PHP. My approach was to create a whole web application and use well-known patterns for the components. But I also asked myself, why to reinvent everything? So I was looking for a framework that matches my actions, that will help me to create an application in-time and has an object-oriented style with a lot of design patterns, to get a glue how a professional architecture looks like. Then I was concentrating on the implementation of these patterns. My decision came in favor of the Zend Framework. [Zend Framework] So, why use the Zend Framework? It’s very customizable. All its components are loosely coupled, that makes it interesting for profiling purposes. But it’s also designed for professional use in mind. The development rules are pretty serious how the code is maintained. And all the components included make your development faster. [also: simplicity, stability] So, let’s see what’s under the hood. [Design Patterns] Design Patterns. They always let us drool and fool about them. But in fact, we need them to create consistent and reliable code, because every pattern describes a general problem, which occurs over and over again. Let’s face some patterns I admired the most during my development. [MVC] First of all there’s the Model View Controller in combination with a Front Controller. The Front Controller acts like a single entry point and centralizes our requests. It creates a request object and routes it to the right Action Controller. The Action Controller contains all the logic needed and uses the request object and the provided models to handle the request. The data extracted will be forwarded to a view that contains the presentation logic. This information will be encapsulated in a response object that the Front Controller will return. [Dependency Injection] Dependency Injections abstract the behavior or configuration of a class. Mostly, the class then aggregates another object to delegate actions. This makes the component more modular and enhances the flexibility and testability. [Adapter] The Adapter is a middle layer to create consistent access to external resources. So if they have different controls, the adapter specifies the command and the return type of similar actions. [Onion] And what do you think is in my opinion the greatest advantage of them all? [Onion] THEY CREATE LAYERS. And that is perfect for profiling… [Profiling] The web application was profiled by Xdebug. It creates a Cachegrind-kind of file that can be used visualization software like KCachegrind. To sum it up, I have a nice Call Graph out of the application that compares the theoretical work flow with the work flow drawn by the profiler. [Call Graph] So this is the only complex slide, but that’s how the profiling output is. As you can see, this call graph is about a requested action of my project. You can see the single entry point of the Front Controller in red that uses the provided parameters to dispatch the request to the Action Controller in blue. Inside of the Action Controller happens the most interesting part, the current logic of the application. You can also see the database queries, which make a great impact on the performance as well. This is an absolute view of the profiled functions that means the cost of every function is absolute to the whole costs. You can also turn on a relative view that shows the relative costs to the parent function. In this case, the costs are in percentage because it is better for the overview. But the actual costs are measured in microseconds. You can also see the calls repeating. There are also alternative views, like a call map or a list and the use of them depends on your plans. [Web Application] So now the last open question for today is: How would you like your web application. [Try Again] Zend F

TRANSCRIPT

Page 1: Zend Framework Design Patterns, Profiling

PHP Design Patterns and Profiling – supported by the Zend FrameworkMartin Buchmayr

Supervisor: Michael Ulm

Page 2: Zend Framework Design Patterns, Profiling
Page 3: Zend Framework Design Patterns, Profiling
Page 4: Zend Framework Design Patterns, Profiling

Model View Controller - Front Controller

Page 5: Zend Framework Design Patterns, Profiling

Dependency Injection - IoC

Page 6: Zend Framework Design Patterns, Profiling

Adapter

Page 7: Zend Framework Design Patterns, Profiling
Page 8: Zend Framework Design Patterns, Profiling
Page 9: Zend Framework Design Patterns, Profiling
Page 10: Zend Framework Design Patterns, Profiling