SlideShare una empresa de Scribd logo
1 de 133
Zend Framework Workshop By Kevin Schroeder Technology Evangelist Zend Technologies
About me Kevin Schroeder Technology Evangelist for Zend Programmer Sys Admin Author IBM i Programmer’s Guide to PHP You want to do WHAT with PHP?  Race Ferraris on the weekend My Honda has a dismal win record
Follow us! Zend Technologies http://twitter.com/zend http://twitter.com/kpschrade (me!) www.eschrade.com
A quick note on Zendcon… BE THERE!! ,[object Object]
Discover new advances
Gain new insights
Deploy and scale large PHP applications
Explore new technologies like NoSQL and Cloud Computing
Learn how to effectively leverage Zend Framework and Zend Framework 2.0,[object Object]
Agenda The Basics Introduction Coding Standards Installing Zend Framework Autoloading Zend_Session Zend_Config Zend_Mail Zend_Validate Zend_Filter Zend_Translate Zend_Form MVC ,[object Object]
Zend_Application
Zend_Db
Table/Row Data Gateway
Services
Theory
Zend_Json_Server
Zend_Amf
Zend_Service_Twitter,[object Object]
Sample PHP Script <html> <head></head> <body> <?php function questionp($input) {     return strrpos ( $input, '?' ) === strlen ( $input ) - 1; } ?> <?php if (! isset( $_POST ['submit'] )) { // if the "submit" variable does not exist the form has not been submitted, so display form ?> <form action="<?phpecho $_SERVER['PHP_SELF']; ?>"method="post"> Enter your question: <input name="question" size="50"> <input type="submit" name="submit" value="Ask"> </form> <?php } else { // if the "submit" variable exists the form has been submitted, so look for and process form data, // displaying the result if(questionp($_POST['question'])) { if(rand(0, 1)): echo 'yes'; else: echo 'no'; endif; } else { echo 'Donapos;t you know what a question is?';     } } ? PHP: Past and Present | 8
Anatomy of a PHP Application PHP: Past and Present Presentation Application Control Database Access Business Logic Presentation Application Control Business Logic Presentation | 9
Anatomy of a PHP Application PHP: Past and Present index.php3 index.php3 index.php3 index.php | 10
Anatomy of a PHP Application PHP: Past and Present index.php3 index.php3 index.php3 index.php index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php | 11
Anatomy of a PHP Application PHP: Past and Present index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php | 12
Anatomy of a PHP Application PHP: Past and Present index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 | 13 |
Anatomy of a Modern PHP Application  |   22-Sep-10 PHP: Past and Present Presentation Something.phtml Something.phtml Something.phtml Something.phtml Something.phtml Something.phtml Something.phtml Something.phtml Application Control Something.php Something.php Something.php Something.php Something.php Something.php Something.php Something.php Business Logic Something.php Something.php Something.php Something.php Something.php Something.php Something.php Something.php Database Access Something.php Something.php Something.php Something.php Something.php Something.php Something.php Something.php | 14
Zend Framework Make everything as simple as possible, but no simpler. 	- Albert Einstein
PHP Problems How can we promote reuse and standards in a strong culture of decentralization? How can we propagate best practices across a community of cowboy coders numbering in the millions? How do we manage the newfound complexity of large PHP applications? How do we promote integration with commercial technologies in a community that has been developed in parallel to these technologies? How do we write better PHP applications?  |   22-Sep-10 Name of this section | 16
The Answer? Name of this section | 17
What is Zend Framework? An open source, MVC-based, full-featured PHP framework A set of use-at-will components; a component library A vehicle through which Zend disseminates best practices A community A philosophy A standard A gateway to the larger PHP community  |   22-Sep-10 PHP: Past and Present | 18
What sets ZF apart? High quality code; all components have unit test coverage of > 80% (both lines and branches) and the tests are run against the framework continuously A use-at-will architecture that allows developers to mix and match their favorite technologies A contribution process that both guarantees quality and encourages active community contributions while protecting against intellectual property claims We only tackle problems when we can bring value that isn’t currently available in the PHP community We believe that web services must be first-class citizens for today’s Web 2.0 applications  |   22-Sep-10 PHP: Past and Present | 19
Our Technology Partners … and more
Supported by All Popular PHP IDEs
Over 50 Books Written
74% of all Zend Framework Applications are Business-Critical * Zend Framework Developer Survey, Dec. 2009
Dojo Integration + In May, 2008 Zend announced a collaboration between the Zend Framework and Dojo Toolkit projects. Zend Framework 1.6 contains the first integration points between these 2 projects: JSON-RPC Server dojo.data Envelopes Dojo View Helper Dijit integration with Zend_Form & Zend_View Dojo Library Re-distribution
Autumn, 2008 Download & InstallZend Framework Download the latest version of Zend Framework and extract the contents of the library folder to your project's library directory http://framework.zend.com/download You should now find the top-level Zend directory which contains all Zend Framework components under your library directory That's it! Zend Framework is now installed and ready to use
Autumn, 2008 What’s in Zend Framework? ,[object Object],MVC web app framework(model-view-controller) Database access Lucene-compatible Search engine Input filtering and validation Authentication Access control Session handling I18N, locales, translation PDF file reading and writing HTTP client Form Handling XML-RPC REST web services RSS and Atom feeds Logging Mail reading and sending Caching Configuration files Command-line option parsing MUCH, MUCH more!
Autumn, 2008 Zend Framework Overview
Where to start
Don’t start with MVC first There are MANY libraries that you can utilize first A trustworthy saying “Don’t use a framework until you know why you need a framework” Don’t use MVC until you know you need MVC Or have at least experienced the pain of managing a large application without it
Things to know All ZF-based classes start with Zend_ If you build a library that utilizes ZF, do not prefix your classes with that (breaks coding standards) Use the autoloader Use plugin loaders Start small
Coding Standards Files with ONLY PHP code start with <?php and have no closing tag Indentation uses 4 spaces, tabs not allowed Lines end with Unix EOL Class naming standards changed after 1.9 to prepare for PHP 5.3 and ZF 2 Function/method declarations  Anything marked private/protected is prefaced with an underscore (private $_var = null) Numbers are permitted in variable/method/function names, but are not recommended
Coding Standards Globally defined variables/functions are allowed, but not recommended (use registry/static methods instead) Variables/methods/functions are named using camelCase There is some debate one what a camel looks like when using an acronym (e.g. PDF) Global constants are allowed, but discouraged.  Use class constants instead Class constants should be UPPER_CASE_WITH_UNDERSCORE “Variable substitution is {$allowed} but not ${allowed}” ‘If no variable substitution is needed then use single quotes’ For arrays, negative index keys are not allowed
Coding Standards One class per file Braces Final brace is always on its own line Method/function calls start on the next line Conditional statements/loops start on the same line Break clauses MUST have a default All functions/methods/class members MUST have a PHPDoc block Read the coding standards at http://framework.zend.com/ in the docs
How to start? Start simple, use utility classes Zend_Loader Zend_Date Zend_Config Zend_Session Zend_Translate Zend_Validate Zend_Filter Zend_Form (!) Others
Utility Classes
Zend_Loader Used to include files for classes that have not been loaded yet It searches the include_path for the requested class  Two types of loaders Autoloader Just a standard autoloader PluginLoader Used for loading classes based off of a prefix
Zend_Loader_Autoloader Initialize Zend_Loader_Autoloader::getInstance(); Register pseudo namespace Zend_Loader_Autoloader::getInstance()   ->registerNamespace('Myapp_'); Set the autoloader for all namespaces Zend_Loader_Autoloader::getInstance()   ->setFallbackAutoloader(true);
Zend_Loader_Pluginloader Used to load named classes, not autoload Used extensively by several ZF components
Zend_Loader_Pluginloader /library/MyApp/MyComponent/Classone.php /library/MyApp/AnotherComponent/Classtwo.php $loader = new Zend_Loader_PluginLoader(); $loader->addPrefixPath(     'MyApp_MyComponent',     'MyApp/MyComponent'); $loader->addPrefixPath(     'MyApp_AnotherComponent',     'MyApp/AnotherComponent');
Zend_Loader_Pluginloader $loader->load('Classone'); $loader->load('Classtwo');
Zend_Session Use this instead of $_SESSION.  Why? Works much better for complex applications Allows for easier separation of components $ns = new Zend_Session_Namespace('Component-1'); $ns = new Zend_Session_Namespace('Component-2');
Zend_Session Good API (standard session ext has very minimal API) public function lock(); public function unlock(); public function apply($callback); public function applySet($callback); public functionsetExpirationSeconds(     $seconds,     $variables = null ); public function setExpirationHops(     $hops,     $variables = null,     $hopCountOnUsageOnly = false );
Zend_Config Provides a way of dealing with configuration A consistent API for getting and setting values Implements Countable, Iterator (uses SPL) Existing mechanisms PHP Arrays (great with opcode caches) INI Files XML Files Your own (Don’t use the DB)
Zend_Config Generally used for Database adapter credentials Caching options Paths Zend_Application uses a LOT of configuration
Using Zend Config You can retrieve data by section
Using Zend_Config You can have inheritance between sections Best practice: inherit from [production]
Zend_Validate Used to provide integratable validation tooling Don’t build it yourself!! Some example validators Email Address Credit Card String Length Host name And about 80 others Chainable using new Zend_Validate()
Zend_Validate – Building your own Must implement Zend_Validate_Interface Zend_Validate_Abstract is a better choice to extend Constructor is optional, used for passing options
Zend_Filter Used to filter data Some examples HtmlEntities Encrypt/Decrypt StripTags StripNewLines
Zend_Form New to ZF 1.5 (one of the best features) Handles Rendering the form Escaping your output Filtering your input Validating your data
Zend_Form – Simple usage $form = new Zend_Form(); $form->setMethod('POST'); $form->setAction('/submitform.php'); $form->setView(new Zend_View()); $form->addElement('text', 'email'); $form->addElement('text', 'name'); $form->addElement('submit', 'submit'); echo $form;
Zend_Form – Less simple usage Forms and form elements have a LOT of options $form->addElement(     'text',     'email',     array(         'label'    => 'Email',         'required' => true     ) );
Zend_Form – Adding validators $form->addElement(     'text',     'email',     array(         'label'=> 'Email',         'required'=> true,         'validators'=> array(             'EmailAddress'         )     ) ); Don’t use validator objects; name them instead But make sure to test that they work
Zend_Form – Adding filters $form->addElement(     'text',     'name',     array(         'label'=> 'Name',         'required'=> true,         'filters'=> array(             'Alpha'         )     ) );
Zend_Form - trick All of the configuration parameters are passed to getters and setters Want to know what configuration options are available?  Look at the setters setLabel() = array(‘label’ => ‘name’) setValidators() setName() setOrder() setRequired()
Zend_Form – Architecting your app Best practices Subclass Zend_Form Very reusable Very testable Create forms to match your existing data structure Have pre-defined forms that match up to existing models Let the designers worry about layout Zend_Form allows for CSS heavy design (ok, that’s good and bad )
Zend_Form – Architecting your app If using with MVC Place in /application/forms Preface with Form_ Use a plugin loader If not Place it in a standard library path and use the autoloader
Zend_Log Concepts Logger – usually an instance of Zend_Log Writer – the mechanism which writes the log entry to the storage medium Must extend Zend_Log_Writer_Abstract Filter – used to determine IF a log entry should be sent to the writer Must implement Zend_Log_Filter_Interface Formatter – creates the text string that will be sent to the writer
Zend_Log Several logging levels (BSD syslog) EMERG - Emergency: system is unusable ALERT - Alert: action must be taken immediately CRIT - Critical: critical conditions ERR - Error: error conditions WARN - Warning: warning conditions NOTICE - Notice: normal but significant condition INFO - Informational: informational messages DEBUG - Debug: debug messages
Zend_Log Available writers Db Firebug Mail Mock Can write to multiple writers at a time Each writer can have multiple filters ,[object Object]
Stream
Syslog
ZendMonitor,[object Object]
MVC Model An object that represents a unit of data/functionality View The user interface Controller Where your business logic lies
MVC It’s best to not use “pure” MVC Use the “thin controller” architecture Place as much of your business logic in the model as possible Reduces code duplication Enhances code testability
Zend_Controller Component where the Controller portion of MVC resides Several concepts Front Controller Action Controller Plugins Helpers
Zend_Controller – Start to finish Front controller Router Dispatcher Action controller
MVC Request Lifecycle dispatch() – Starts the dispatch process routeStartup() – Called prior to parsing the URL for the request routeShutdown() – Called immediately after the module, controller and action have been determined dispatchLoopStartup() – Called immediately before the dispatch loop starts preDispatch() – Called at the beginning of each dispatch loop
MVC Request Lifecycle init() – Called from inside the controller’s constructor preDispatch() – Called for each action helper that is currently initialized preDispatch() – A hook on the current controller object  *Action() – The individual action that was requested during the routing process postDispatch() – A hook in the current controller object
MVC Request Lifecycle postDispatch() – Called for each loaded action helper postDispatch() – Called for each plugin dispatchLoopShutdown() – The last hook to be executed
Front Controller The “access point” for the application
Action Controllers Extends Zend_Controller_Action Access $_GET, $_POST via request object Pass output/headers to response object
Accessing an action controller
Controller Plugins Allows you to execute functionality at some point along the execution chain Plugins are typically not interactive like helpers Need to extend Zend_Controller_Plugin_Abstract
Controller Plugins – Hooks
ControllerPlugin - Example class Esc_Application_Plugin_Maintenance 	extends Zend_Controller_Plugin_Abstract {     public function routeShutdown(Zend_Controller_Request_Abstract $request)     {         $request->setActionName('index');         $request->setModuleName('default');         $request->setControllerName('maintenance');     }  }
Controller Helpers Inject on-demand functionality into action controllers Cache Context Switching (“Do I use HTML, JSON, XML?”) View Renderer Build your own Minimize the need to extend Zend_Controller_Action Has init(), preDispatch(), postDispatch() hooks Only called if a helper object has been instantiated
Controller Helpers – Building your own Must extend Zend_Controller_Action_Helper_Abstract Must be registered with the helper broker Zend_Controller_Action_HelperBroker::addPath( 	APPLICATION_PATH.'/helpers', 	'Helper' ); Call from the controller $this->_helper->Sendemail( 	'Kevin Schroeder', 	'kevin@zend.com', 	'We did something in the last request' );
Zend_View Used to handle the view (user interface) from BL Older style apps have the two mixed Can be used separately from MVC (if you like) Useful if you want to re-use view helpers or form components If using MVC, generally stored in controllers/../views/script
Zend_View – Step 1: Assigning data $data = array(     array(         'author' => 'Kevin Schroeder',         'title' => 'The IBM i Programmerapos;s Guide to PHP'        ),     array(         'author' => 'Kevin Schroeder',         'title' => 'You want to do WHAT with PHP?'        ) ); Zend_Loader::loadClass('Zend_View'); $view = new Zend_View(); $view->books = $data; echo $view->render('booklist.php');
Zend_View – Step 2: Rendering data <?php if ($this->books): ?>       <table>       <tr>         <th>Author</th>             <th>Title</th>         </tr>         <?phpforeach ($this->books as $key => $val): ?>         <tr>         <td><?php echo $this->escape($val['author']) ?></td>             <td><?php echo $this->escape($val['title']) ?></td>         </tr>         <?phpendforeach; ?>   </table> <?php else: ?> <p>There are no books to display.</p> <?phpendif;?>
Using the ViewRenderer An action helper that is loaded by default Executes in the postDispatch() hook Examines the controller/action combination and automatically runs the proper view script IndexController::indexAction() /views/scripts/index/index.phtml
View Helpers View helpers make your life easier Used to provide additional functionality similar to an action helper, but for the view Referenced via the $this object when in a view Loaded using a plugin loader Used to keep logic out of the view (very important) Try to limit views to if and foreach statements
View Helpers Examples Easy translation integration echo $this->translate('Hello World'); Capturing JS so it can be output elsewhere <?php $this->headScript()->captureStart(); ?> alert('Hello World'); <?php $this->headScript()->captureEnd(); ?>
View Helpers You can build your own! Does not need to implement any interface or abstract class Generally placed in /views/helpers (configurable) Must have a method name defined as the same name of the class My_Helper_Sendemail must have a method called sendemail(). class My_Helper_Sendemail { 	public function sendemail($to, $subject, $message) 	{ 		// Haven't gotten to Zend_Mail yet :-) 		mail($to, $subject, $message); 	} }
Using Partials Partials are used to render small, re-usable portions of the view Handled via a view helper Partial PartialLoop Very useful for any iterative functionality Arrays Zend_Db_Table_Rowset Anything implementing the Iterator interface
The Model Unlike other frameworks it is any class that represents your data or business logic Could be a service object Could be a text file Could be an LDAP entry Could be a Zend_Db object
Zend_Db Database abstraction layer (as opposed to access abstraction layer) Several different database vendors are supported Abstractions for common functionality such as select, insert, update, delete, limit, offset or transactions Connects to the database on demand Adapter instance is usually created via Zend_Db::factory() Integrated database profiling
Zend_Db_Select Provides a vendor-independent mechanism for creating select statements Very useful, but be careful of the unintended consequences of abstraction $select->from('table')    ->where('table_id = ?', $_GET[‘val']); Output: SELECT `table`.* FROM `table` WHERE (table_id = ?) Supports multiple join types, where, group by, order, etc.
ORM Uses the Table/Row Data Gateway Design Patterns One class to represent the table One class to represent a row in the table
ORM – The Table Table classes extend Zend_Db_Table_Abstract Handles references to other tables  class Model_DbTable_Comment extends Zend_Db_Table_Abstract {     protected $_name = 'comment';     protected $_rowClass = 'Model_Comment';     protected $_referenceMap    = array(         'Content' => array(             'columns'           => 'content_key',             'refTableClass'     => 'Model_DbTable_Content',             'refColumns'        => 'content_key'         ),     ); }
ORM – The Row Model classes extend Zend_Db_Table_Row_Abstract class Model_City extends Zend_Db_Table_Row_Abstract { } Row data is accessed via a __get call Good idea to use getters and setters to access them (great for code completion)
Fetching Data $dbTable = new Model_DbTable_Comment(); $comment = $dbTable->find($_GET['id']); $dbTable = new Model_DbTable_Comment(); $select = $dbTable->select()   ->where('active = ?', $_GET['active']); $comment = $dbTable->fetchRow()->current();
ORM - Relationships Retrieve an instance of the row class Call a wacked method call which calls __call() and figures out which db table object to load and query on. class Model_DbTable_Comment extends Zend_Db_Table_Abstract {     protected $_name = 'comment';     protected $_rowClass = 'Model_Comment';     protected $_referenceMap    = array(         'Content' => array(             'columns'           => 'content_key',             'refTableClass'     => 'Model_DbTable_Content',             'refColumns'        => 'content_key'         ),     ); }
Calling a related object $tabs = $comment       ->findModel_DbTable_TagViaModel_DbTable_TagContent(); Write a getter that defines that in your model class Model_Content extends Esc_ModelAbstract {     public function getTags()     {         return $this             ->findModel_DbTable_TagViaModel_DbTable_TagContent()     } }
Unit Testing MVC
Unit Testing Why Unit Test? Simplify maintenance It defines expectations  It describes behaviors identified by the application  It tells us when new changes break existing code and behaviors
Terms Unit The piece of code you are testing Test A piece of code that calls the piece of code you’re testing Assertion Validating return types or results of the test Code Coverage A report on which lines of code have been tested Used to determine additional tests that need to be written Continuous Integration The continuous application of quality control, i.e. unit tests
Testing the model The easiest of all Test classes typically extend PHPUnit_Framework_TestCase
Testing the controller Setting up the test Test class extends Zend_Test_PHPUnit_ControllerTestCase If testing Zend_Application make sure you add the bootstrap in the setUp() method Make sure you reset() your tests Response Request Layout Helper Broker
Testing the controller You can test Routing (also good for checking authorization) Response codes Output (we’ll look at that next)
Testing the view Best tested through the controller Define which HTML elements need to be present on the page and verify that they exist or have certain values Can be done using CSS Selectors Xpath Queries
Zend_Layout Implements Two Step View pattern Same name as a dance in Texas, but that’s not important
A little more advanced…
Zend_Application Used for defining an application context Zend_Controller_Front just handled the brokering of the request Zend_Application handles  Bootstrapping (dev/testing/staging/production) Creating the autoloader Dispatching Resource creation
Bootstrapping Implements Zend_Application_Bootstrap_Bootstrapper Used to bootstrap (set up the environment) and then execute the request Most applications can simply extend Zend_Application_Bootstrap_Bootstrap This is what we will assume you are using
Bootstrapping Resource methods Use the resource autoloader  Zend_Application_Module_Autoloader placed in _initAutoload() Order Zend_Application::bootstrap() Bootstrap class instantiated Any methods starting with _init() are called and the return value is placed in a container Action retrieves the resource through calling getInvokeArg() and naming the resource
Bootstrapping Bootstrap class is instantiated every time so DON’T put everything there (horrible for performance, PHP loves lazy loading) One option is to override hasResource() method in Bootstrap so that it instantiates a resource only when it is needed Best practice?  Don’t know.  Kevin’s practice?  Yes.  Therefore it is good
Resources Pluggable pieces of functionality tied to the application Ties functionality directly in with the configuration Sample of existing plugins Cachemanager Db Log Frontcontroller Translate
Services
Service Theory Many services have a very similar execution flow Receive request Find class that can service the request Instantiate object that can handle the request Return result to client Why re-invent the wheel?
Zend_Server Base component for several service-oriented components Primarily used for reflection and a standard interface Actual implementation is left to component
Zend_*_Server Several components implement Zend_Server_Abstract Useful for standardized web service implementation foreach (glob(APPLICATION_PATH.'/mappers/*.php') as $dir) { $name = substr(basename($dir), 0, -4);     $class = 'Mapper_' . $name;     $serviceHandler->setClass($class, $name); } echo $serviceHandler->handle(); Using data mappers are your key to happiness $serviceHandler = new Zend_Json_Server(); $serviceHandler = new Zend_Amf_Server(); $serviceHandler = new Zend_Xml_Server();
Writing Re-usable Models Write your application logic once, but use it in many different ways Why?  MVC is only one consumer Can be called by job scripts, message systems, queues, etc. Service endpoints can act as consumers(Hint: JSON-RPC is a good way to feed your Ajax applications) 112
What? ,[object Object]
The individual resources and units of work in your application
E.g. user, team, backlog, sprint, etc.
E.g., object relations, transactions, queries
Service Layers
Public API of the application; i.e., the behaviors you wish to expose
Logic for injecting dependencies,[object Object]
Benefits to Service Layers ,[object Object]

Más contenido relacionado

La actualidad más candente

API Documentation -- Presentation to East Bay STC Chapter
API Documentation -- Presentation to East Bay STC ChapterAPI Documentation -- Presentation to East Bay STC Chapter
API Documentation -- Presentation to East Bay STC ChapterTom Johnson
 
PHP Interview Questions and Answers | Edureka
PHP Interview Questions and Answers | EdurekaPHP Interview Questions and Answers | Edureka
PHP Interview Questions and Answers | EdurekaEdureka!
 
Listen and look at your PHP code
Listen and look at your PHP codeListen and look at your PHP code
Listen and look at your PHP codeGabriele Santini
 
Object oriented-programming-in-c-sharp
Object oriented-programming-in-c-sharpObject oriented-programming-in-c-sharp
Object oriented-programming-in-c-sharpAbefo
 
Hack in the Box GSEC 2016 - Reverse Engineering Swift Applications
Hack in the Box GSEC 2016 - Reverse Engineering Swift ApplicationsHack in the Box GSEC 2016 - Reverse Engineering Swift Applications
Hack in the Box GSEC 2016 - Reverse Engineering Swift Applicationseightbit
 
Introduction to c_sharp
Introduction to c_sharpIntroduction to c_sharp
Introduction to c_sharpHEM Sothon
 
Net serialization
Net serializationNet serialization
Net serializationGreg Sohl
 
Php Interview Questions
Php Interview QuestionsPhp Interview Questions
Php Interview QuestionsUmeshSingh159
 
Using Zend_Tool to Establish Your Project's Skeleton
Using Zend_Tool to Establish Your Project's SkeletonUsing Zend_Tool to Establish Your Project's Skeleton
Using Zend_Tool to Establish Your Project's SkeletonJeremy Brown
 
How To Become A Good C# Programmer
How To Become A Good C# ProgrammerHow To Become A Good C# Programmer
How To Become A Good C# ProgrammerLearnItFirst.com
 
Rootcon X - Reverse Engineering Swift Applications
Rootcon X - Reverse Engineering Swift ApplicationsRootcon X - Reverse Engineering Swift Applications
Rootcon X - Reverse Engineering Swift Applicationseightbit
 
PHP Interview Questions for Freshers 2018
PHP Interview Questions for Freshers 2018PHP Interview Questions for Freshers 2018
PHP Interview Questions for Freshers 2018AshokKumar3319
 
Php Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant KillerPhp Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant KillerJackson F. de A. Mafra
 
GTU MCA PHP Interview Questions And Answers for freshers
GTU MCA PHP  Interview Questions And Answers for freshersGTU MCA PHP  Interview Questions And Answers for freshers
GTU MCA PHP Interview Questions And Answers for freshersTOPS Technologies
 

La actualidad más candente (17)

API Documentation -- Presentation to East Bay STC Chapter
API Documentation -- Presentation to East Bay STC ChapterAPI Documentation -- Presentation to East Bay STC Chapter
API Documentation -- Presentation to East Bay STC Chapter
 
PHP Interview Questions and Answers | Edureka
PHP Interview Questions and Answers | EdurekaPHP Interview Questions and Answers | Edureka
PHP Interview Questions and Answers | Edureka
 
T4 presentation
T4 presentationT4 presentation
T4 presentation
 
Guidelines php 8 gig
Guidelines php 8 gigGuidelines php 8 gig
Guidelines php 8 gig
 
Listen and look at your PHP code
Listen and look at your PHP codeListen and look at your PHP code
Listen and look at your PHP code
 
Object oriented-programming-in-c-sharp
Object oriented-programming-in-c-sharpObject oriented-programming-in-c-sharp
Object oriented-programming-in-c-sharp
 
Hack in the Box GSEC 2016 - Reverse Engineering Swift Applications
Hack in the Box GSEC 2016 - Reverse Engineering Swift ApplicationsHack in the Box GSEC 2016 - Reverse Engineering Swift Applications
Hack in the Box GSEC 2016 - Reverse Engineering Swift Applications
 
Introduction to c_sharp
Introduction to c_sharpIntroduction to c_sharp
Introduction to c_sharp
 
Net serialization
Net serializationNet serialization
Net serialization
 
Php Interview Questions
Php Interview QuestionsPhp Interview Questions
Php Interview Questions
 
Java notes
Java notesJava notes
Java notes
 
Using Zend_Tool to Establish Your Project's Skeleton
Using Zend_Tool to Establish Your Project's SkeletonUsing Zend_Tool to Establish Your Project's Skeleton
Using Zend_Tool to Establish Your Project's Skeleton
 
How To Become A Good C# Programmer
How To Become A Good C# ProgrammerHow To Become A Good C# Programmer
How To Become A Good C# Programmer
 
Rootcon X - Reverse Engineering Swift Applications
Rootcon X - Reverse Engineering Swift ApplicationsRootcon X - Reverse Engineering Swift Applications
Rootcon X - Reverse Engineering Swift Applications
 
PHP Interview Questions for Freshers 2018
PHP Interview Questions for Freshers 2018PHP Interview Questions for Freshers 2018
PHP Interview Questions for Freshers 2018
 
Php Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant KillerPhp Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant Killer
 
GTU MCA PHP Interview Questions And Answers for freshers
GTU MCA PHP  Interview Questions And Answers for freshersGTU MCA PHP  Interview Questions And Answers for freshers
GTU MCA PHP Interview Questions And Answers for freshers
 

Destacado

Exporting from data director, Importing into PowerSchool
Exporting from data director, Importing into PowerSchoolExporting from data director, Importing into PowerSchool
Exporting from data director, Importing into PowerSchoolDerek D'Angelo
 
Eudora e mail instructions
Eudora e mail instructionsEudora e mail instructions
Eudora e mail instructionsDerek D'Angelo
 
Oakland Schools Economics Moodle, Unit 3, Lesson 3 GPI Slides
Oakland Schools Economics Moodle, Unit 3, Lesson 3 GPI SlidesOakland Schools Economics Moodle, Unit 3, Lesson 3 GPI Slides
Oakland Schools Economics Moodle, Unit 3, Lesson 3 GPI SlidesDerek D'Angelo
 
Oakland Schools Economics Moodle, Unit 3, Lesson 3
Oakland Schools Economics Moodle, Unit 3, Lesson 3Oakland Schools Economics Moodle, Unit 3, Lesson 3
Oakland Schools Economics Moodle, Unit 3, Lesson 3Derek D'Angelo
 

Destacado (7)

Blackboard
BlackboardBlackboard
Blackboard
 
Exporting from data director, Importing into PowerSchool
Exporting from data director, Importing into PowerSchoolExporting from data director, Importing into PowerSchool
Exporting from data director, Importing into PowerSchool
 
Eudora e mail instructions
Eudora e mail instructionsEudora e mail instructions
Eudora e mail instructions
 
Ikeepbookmarks
IkeepbookmarksIkeepbookmarks
Ikeepbookmarks
 
Oakland Schools Economics Moodle, Unit 3, Lesson 3 GPI Slides
Oakland Schools Economics Moodle, Unit 3, Lesson 3 GPI SlidesOakland Schools Economics Moodle, Unit 3, Lesson 3 GPI Slides
Oakland Schools Economics Moodle, Unit 3, Lesson 3 GPI Slides
 
Inservice stations
Inservice stationsInservice stations
Inservice stations
 
Oakland Schools Economics Moodle, Unit 3, Lesson 3
Oakland Schools Economics Moodle, Unit 3, Lesson 3Oakland Schools Economics Moodle, Unit 3, Lesson 3
Oakland Schools Economics Moodle, Unit 3, Lesson 3
 

Similar a Zend Framework Workshop (20)

Demo
DemoDemo
Demo
 
first pitch
first pitchfirst pitch
first pitch
 
werwr
werwrwerwr
werwr
 
sdfsdf
sdfsdfsdfsdf
sdfsdf
 
college
collegecollege
college
 
first pitch
first pitchfirst pitch
first pitch
 
Greenathan
GreenathanGreenathan
Greenathan
 
Unit Test for ZF SlideShare Component
Unit Test for ZF SlideShare ComponentUnit Test for ZF SlideShare Component
Unit Test for ZF SlideShare Component
 
first pitch
first pitchfirst pitch
first pitch
 
organic
organicorganic
organic
 
first pitch
first pitchfirst pitch
first pitch
 
latest slide
latest slidelatest slide
latest slide
 
345
345345
345
 
before upload
before uploadbefore upload
before upload
 
Unit Test for ZF SlideShare Component
Unit Test for ZF SlideShare ComponentUnit Test for ZF SlideShare Component
Unit Test for ZF SlideShare Component
 
sadasd
sadasdsadasd
sadasd
 
asdfasd
asdfasdasdfasd
asdfasd
 
before upload
before uploadbefore upload
before upload
 
before upload
before uploadbefore upload
before upload
 
Greenathan
GreenathanGreenathan
Greenathan
 

Más de 10n Software, LLC

Delaying Gratification: Using queues to build efficient systems
Delaying Gratification: Using queues to build efficient systemsDelaying Gratification: Using queues to build efficient systems
Delaying Gratification: Using queues to build efficient systems10n Software, LLC
 
Flex and PHP For the Flash Folks
Flex and PHP For the Flash FolksFlex and PHP For the Flash Folks
Flex and PHP For the Flash Folks10n Software, LLC
 
PHP Performance: Principles and tools
PHP Performance: Principles and toolsPHP Performance: Principles and tools
PHP Performance: Principles and tools10n Software, LLC
 
Application Deployment with Zend Server 5.5 beta
Application Deployment with Zend Server 5.5 betaApplication Deployment with Zend Server 5.5 beta
Application Deployment with Zend Server 5.5 beta10n Software, LLC
 
Creating stunning data analytics dashboard using php and flex
Creating stunning data analytics dashboard using php and flexCreating stunning data analytics dashboard using php and flex
Creating stunning data analytics dashboard using php and flex10n Software, LLC
 
Slideshare - Magento Imagine - Do You Queue
Slideshare - Magento Imagine - Do You QueueSlideshare - Magento Imagine - Do You Queue
Slideshare - Magento Imagine - Do You Queue10n Software, LLC
 
Slides from LAX & DEN usergroup meetings
Slides from LAX & DEN usergroup meetingsSlides from LAX & DEN usergroup meetings
Slides from LAX & DEN usergroup meetings10n Software, LLC
 

Más de 10n Software, LLC (15)

Delaying Gratification: Using queues to build efficient systems
Delaying Gratification: Using queues to build efficient systemsDelaying Gratification: Using queues to build efficient systems
Delaying Gratification: Using queues to build efficient systems
 
10 things
10 things10 things
10 things
 
Flex and PHP For the Flash Folks
Flex and PHP For the Flash FolksFlex and PHP For the Flash Folks
Flex and PHP For the Flash Folks
 
PHP Performance: Principles and tools
PHP Performance: Principles and toolsPHP Performance: Principles and tools
PHP Performance: Principles and tools
 
Application Deployment with Zend Server 5.5 beta
Application Deployment with Zend Server 5.5 betaApplication Deployment with Zend Server 5.5 beta
Application Deployment with Zend Server 5.5 beta
 
Do you queue (updated)
Do you queue (updated)Do you queue (updated)
Do you queue (updated)
 
Flex for php developers
Flex for php developersFlex for php developers
Flex for php developers
 
Creating stunning data analytics dashboard using php and flex
Creating stunning data analytics dashboard using php and flexCreating stunning data analytics dashboard using php and flex
Creating stunning data analytics dashboard using php and flex
 
Php security common 2011
Php security common 2011Php security common 2011
Php security common 2011
 
North east user group tour
North east user group tourNorth east user group tour
North east user group tour
 
Slideshare - Magento Imagine - Do You Queue
Slideshare - Magento Imagine - Do You QueueSlideshare - Magento Imagine - Do You Queue
Slideshare - Magento Imagine - Do You Queue
 
Do you queue
Do you queueDo you queue
Do you queue
 
Zend Server - OSI Days
Zend Server - OSI DaysZend Server - OSI Days
Zend Server - OSI Days
 
Slides from LAX & DEN usergroup meetings
Slides from LAX & DEN usergroup meetingsSlides from LAX & DEN usergroup meetings
Slides from LAX & DEN usergroup meetings
 
Flex and Zend Framework
Flex and Zend FrameworkFlex and Zend Framework
Flex and Zend Framework
 

Último

Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 

Último (20)

Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 

Zend Framework Workshop

  • 1. Zend Framework Workshop By Kevin Schroeder Technology Evangelist Zend Technologies
  • 2. About me Kevin Schroeder Technology Evangelist for Zend Programmer Sys Admin Author IBM i Programmer’s Guide to PHP You want to do WHAT with PHP? Race Ferraris on the weekend My Honda has a dismal win record
  • 3. Follow us! Zend Technologies http://twitter.com/zend http://twitter.com/kpschrade (me!) www.eschrade.com
  • 4.
  • 7. Deploy and scale large PHP applications
  • 8. Explore new technologies like NoSQL and Cloud Computing
  • 9.
  • 10.
  • 18.
  • 19. Sample PHP Script <html> <head></head> <body> <?php function questionp($input) { return strrpos ( $input, '?' ) === strlen ( $input ) - 1; } ?> <?php if (! isset( $_POST ['submit'] )) { // if the "submit" variable does not exist the form has not been submitted, so display form ?> <form action="<?phpecho $_SERVER['PHP_SELF']; ?>"method="post"> Enter your question: <input name="question" size="50"> <input type="submit" name="submit" value="Ask"> </form> <?php } else { // if the "submit" variable exists the form has been submitted, so look for and process form data, // displaying the result if(questionp($_POST['question'])) { if(rand(0, 1)): echo 'yes'; else: echo 'no'; endif; } else { echo 'Donapos;t you know what a question is?'; } } ? PHP: Past and Present | 8
  • 20. Anatomy of a PHP Application PHP: Past and Present Presentation Application Control Database Access Business Logic Presentation Application Control Business Logic Presentation | 9
  • 21. Anatomy of a PHP Application PHP: Past and Present index.php3 index.php3 index.php3 index.php | 10
  • 22. Anatomy of a PHP Application PHP: Past and Present index.php3 index.php3 index.php3 index.php index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php | 11
  • 23. Anatomy of a PHP Application PHP: Past and Present index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php | 12
  • 24. Anatomy of a PHP Application PHP: Past and Present index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 index.php3 | 13 |
  • 25. Anatomy of a Modern PHP Application | 22-Sep-10 PHP: Past and Present Presentation Something.phtml Something.phtml Something.phtml Something.phtml Something.phtml Something.phtml Something.phtml Something.phtml Application Control Something.php Something.php Something.php Something.php Something.php Something.php Something.php Something.php Business Logic Something.php Something.php Something.php Something.php Something.php Something.php Something.php Something.php Database Access Something.php Something.php Something.php Something.php Something.php Something.php Something.php Something.php | 14
  • 26. Zend Framework Make everything as simple as possible, but no simpler. - Albert Einstein
  • 27. PHP Problems How can we promote reuse and standards in a strong culture of decentralization? How can we propagate best practices across a community of cowboy coders numbering in the millions? How do we manage the newfound complexity of large PHP applications? How do we promote integration with commercial technologies in a community that has been developed in parallel to these technologies? How do we write better PHP applications? | 22-Sep-10 Name of this section | 16
  • 28. The Answer? Name of this section | 17
  • 29. What is Zend Framework? An open source, MVC-based, full-featured PHP framework A set of use-at-will components; a component library A vehicle through which Zend disseminates best practices A community A philosophy A standard A gateway to the larger PHP community | 22-Sep-10 PHP: Past and Present | 18
  • 30. What sets ZF apart? High quality code; all components have unit test coverage of > 80% (both lines and branches) and the tests are run against the framework continuously A use-at-will architecture that allows developers to mix and match their favorite technologies A contribution process that both guarantees quality and encourages active community contributions while protecting against intellectual property claims We only tackle problems when we can bring value that isn’t currently available in the PHP community We believe that web services must be first-class citizens for today’s Web 2.0 applications | 22-Sep-10 PHP: Past and Present | 19
  • 31. Our Technology Partners … and more
  • 32. Supported by All Popular PHP IDEs
  • 33. Over 50 Books Written
  • 34. 74% of all Zend Framework Applications are Business-Critical * Zend Framework Developer Survey, Dec. 2009
  • 35. Dojo Integration + In May, 2008 Zend announced a collaboration between the Zend Framework and Dojo Toolkit projects. Zend Framework 1.6 contains the first integration points between these 2 projects: JSON-RPC Server dojo.data Envelopes Dojo View Helper Dijit integration with Zend_Form & Zend_View Dojo Library Re-distribution
  • 36. Autumn, 2008 Download & InstallZend Framework Download the latest version of Zend Framework and extract the contents of the library folder to your project's library directory http://framework.zend.com/download You should now find the top-level Zend directory which contains all Zend Framework components under your library directory That's it! Zend Framework is now installed and ready to use
  • 37.
  • 38. Autumn, 2008 Zend Framework Overview
  • 40. Don’t start with MVC first There are MANY libraries that you can utilize first A trustworthy saying “Don’t use a framework until you know why you need a framework” Don’t use MVC until you know you need MVC Or have at least experienced the pain of managing a large application without it
  • 41. Things to know All ZF-based classes start with Zend_ If you build a library that utilizes ZF, do not prefix your classes with that (breaks coding standards) Use the autoloader Use plugin loaders Start small
  • 42. Coding Standards Files with ONLY PHP code start with <?php and have no closing tag Indentation uses 4 spaces, tabs not allowed Lines end with Unix EOL Class naming standards changed after 1.9 to prepare for PHP 5.3 and ZF 2 Function/method declarations Anything marked private/protected is prefaced with an underscore (private $_var = null) Numbers are permitted in variable/method/function names, but are not recommended
  • 43. Coding Standards Globally defined variables/functions are allowed, but not recommended (use registry/static methods instead) Variables/methods/functions are named using camelCase There is some debate one what a camel looks like when using an acronym (e.g. PDF) Global constants are allowed, but discouraged. Use class constants instead Class constants should be UPPER_CASE_WITH_UNDERSCORE “Variable substitution is {$allowed} but not ${allowed}” ‘If no variable substitution is needed then use single quotes’ For arrays, negative index keys are not allowed
  • 44. Coding Standards One class per file Braces Final brace is always on its own line Method/function calls start on the next line Conditional statements/loops start on the same line Break clauses MUST have a default All functions/methods/class members MUST have a PHPDoc block Read the coding standards at http://framework.zend.com/ in the docs
  • 45. How to start? Start simple, use utility classes Zend_Loader Zend_Date Zend_Config Zend_Session Zend_Translate Zend_Validate Zend_Filter Zend_Form (!) Others
  • 47. Zend_Loader Used to include files for classes that have not been loaded yet It searches the include_path for the requested class Two types of loaders Autoloader Just a standard autoloader PluginLoader Used for loading classes based off of a prefix
  • 48. Zend_Loader_Autoloader Initialize Zend_Loader_Autoloader::getInstance(); Register pseudo namespace Zend_Loader_Autoloader::getInstance() ->registerNamespace('Myapp_'); Set the autoloader for all namespaces Zend_Loader_Autoloader::getInstance() ->setFallbackAutoloader(true);
  • 49. Zend_Loader_Pluginloader Used to load named classes, not autoload Used extensively by several ZF components
  • 50. Zend_Loader_Pluginloader /library/MyApp/MyComponent/Classone.php /library/MyApp/AnotherComponent/Classtwo.php $loader = new Zend_Loader_PluginLoader(); $loader->addPrefixPath( 'MyApp_MyComponent', 'MyApp/MyComponent'); $loader->addPrefixPath( 'MyApp_AnotherComponent', 'MyApp/AnotherComponent');
  • 52. Zend_Session Use this instead of $_SESSION. Why? Works much better for complex applications Allows for easier separation of components $ns = new Zend_Session_Namespace('Component-1'); $ns = new Zend_Session_Namespace('Component-2');
  • 53. Zend_Session Good API (standard session ext has very minimal API) public function lock(); public function unlock(); public function apply($callback); public function applySet($callback); public functionsetExpirationSeconds( $seconds, $variables = null ); public function setExpirationHops( $hops, $variables = null, $hopCountOnUsageOnly = false );
  • 54. Zend_Config Provides a way of dealing with configuration A consistent API for getting and setting values Implements Countable, Iterator (uses SPL) Existing mechanisms PHP Arrays (great with opcode caches) INI Files XML Files Your own (Don’t use the DB)
  • 55. Zend_Config Generally used for Database adapter credentials Caching options Paths Zend_Application uses a LOT of configuration
  • 56. Using Zend Config You can retrieve data by section
  • 57. Using Zend_Config You can have inheritance between sections Best practice: inherit from [production]
  • 58. Zend_Validate Used to provide integratable validation tooling Don’t build it yourself!! Some example validators Email Address Credit Card String Length Host name And about 80 others Chainable using new Zend_Validate()
  • 59. Zend_Validate – Building your own Must implement Zend_Validate_Interface Zend_Validate_Abstract is a better choice to extend Constructor is optional, used for passing options
  • 60. Zend_Filter Used to filter data Some examples HtmlEntities Encrypt/Decrypt StripTags StripNewLines
  • 61. Zend_Form New to ZF 1.5 (one of the best features) Handles Rendering the form Escaping your output Filtering your input Validating your data
  • 62. Zend_Form – Simple usage $form = new Zend_Form(); $form->setMethod('POST'); $form->setAction('/submitform.php'); $form->setView(new Zend_View()); $form->addElement('text', 'email'); $form->addElement('text', 'name'); $form->addElement('submit', 'submit'); echo $form;
  • 63. Zend_Form – Less simple usage Forms and form elements have a LOT of options $form->addElement( 'text', 'email', array( 'label' => 'Email', 'required' => true ) );
  • 64. Zend_Form – Adding validators $form->addElement( 'text', 'email', array( 'label'=> 'Email', 'required'=> true, 'validators'=> array( 'EmailAddress' ) ) ); Don’t use validator objects; name them instead But make sure to test that they work
  • 65. Zend_Form – Adding filters $form->addElement( 'text', 'name', array( 'label'=> 'Name', 'required'=> true, 'filters'=> array( 'Alpha' ) ) );
  • 66. Zend_Form - trick All of the configuration parameters are passed to getters and setters Want to know what configuration options are available? Look at the setters setLabel() = array(‘label’ => ‘name’) setValidators() setName() setOrder() setRequired()
  • 67. Zend_Form – Architecting your app Best practices Subclass Zend_Form Very reusable Very testable Create forms to match your existing data structure Have pre-defined forms that match up to existing models Let the designers worry about layout Zend_Form allows for CSS heavy design (ok, that’s good and bad )
  • 68. Zend_Form – Architecting your app If using with MVC Place in /application/forms Preface with Form_ Use a plugin loader If not Place it in a standard library path and use the autoloader
  • 69. Zend_Log Concepts Logger – usually an instance of Zend_Log Writer – the mechanism which writes the log entry to the storage medium Must extend Zend_Log_Writer_Abstract Filter – used to determine IF a log entry should be sent to the writer Must implement Zend_Log_Filter_Interface Formatter – creates the text string that will be sent to the writer
  • 70. Zend_Log Several logging levels (BSD syslog) EMERG - Emergency: system is unusable ALERT - Alert: action must be taken immediately CRIT - Critical: critical conditions ERR - Error: error conditions WARN - Warning: warning conditions NOTICE - Notice: normal but significant condition INFO - Informational: informational messages DEBUG - Debug: debug messages
  • 71.
  • 74.
  • 75. MVC Model An object that represents a unit of data/functionality View The user interface Controller Where your business logic lies
  • 76. MVC It’s best to not use “pure” MVC Use the “thin controller” architecture Place as much of your business logic in the model as possible Reduces code duplication Enhances code testability
  • 77. Zend_Controller Component where the Controller portion of MVC resides Several concepts Front Controller Action Controller Plugins Helpers
  • 78. Zend_Controller – Start to finish Front controller Router Dispatcher Action controller
  • 79. MVC Request Lifecycle dispatch() – Starts the dispatch process routeStartup() – Called prior to parsing the URL for the request routeShutdown() – Called immediately after the module, controller and action have been determined dispatchLoopStartup() – Called immediately before the dispatch loop starts preDispatch() – Called at the beginning of each dispatch loop
  • 80. MVC Request Lifecycle init() – Called from inside the controller’s constructor preDispatch() – Called for each action helper that is currently initialized preDispatch() – A hook on the current controller object *Action() – The individual action that was requested during the routing process postDispatch() – A hook in the current controller object
  • 81. MVC Request Lifecycle postDispatch() – Called for each loaded action helper postDispatch() – Called for each plugin dispatchLoopShutdown() – The last hook to be executed
  • 82. Front Controller The “access point” for the application
  • 83. Action Controllers Extends Zend_Controller_Action Access $_GET, $_POST via request object Pass output/headers to response object
  • 84. Accessing an action controller
  • 85. Controller Plugins Allows you to execute functionality at some point along the execution chain Plugins are typically not interactive like helpers Need to extend Zend_Controller_Plugin_Abstract
  • 87. ControllerPlugin - Example class Esc_Application_Plugin_Maintenance extends Zend_Controller_Plugin_Abstract { public function routeShutdown(Zend_Controller_Request_Abstract $request) { $request->setActionName('index'); $request->setModuleName('default'); $request->setControllerName('maintenance'); } }
  • 88. Controller Helpers Inject on-demand functionality into action controllers Cache Context Switching (“Do I use HTML, JSON, XML?”) View Renderer Build your own Minimize the need to extend Zend_Controller_Action Has init(), preDispatch(), postDispatch() hooks Only called if a helper object has been instantiated
  • 89. Controller Helpers – Building your own Must extend Zend_Controller_Action_Helper_Abstract Must be registered with the helper broker Zend_Controller_Action_HelperBroker::addPath( APPLICATION_PATH.'/helpers', 'Helper' ); Call from the controller $this->_helper->Sendemail( 'Kevin Schroeder', 'kevin@zend.com', 'We did something in the last request' );
  • 90. Zend_View Used to handle the view (user interface) from BL Older style apps have the two mixed Can be used separately from MVC (if you like) Useful if you want to re-use view helpers or form components If using MVC, generally stored in controllers/../views/script
  • 91. Zend_View – Step 1: Assigning data $data = array( array( 'author' => 'Kevin Schroeder', 'title' => 'The IBM i Programmerapos;s Guide to PHP' ), array( 'author' => 'Kevin Schroeder', 'title' => 'You want to do WHAT with PHP?' ) ); Zend_Loader::loadClass('Zend_View'); $view = new Zend_View(); $view->books = $data; echo $view->render('booklist.php');
  • 92. Zend_View – Step 2: Rendering data <?php if ($this->books): ?> <table> <tr> <th>Author</th> <th>Title</th> </tr> <?phpforeach ($this->books as $key => $val): ?> <tr> <td><?php echo $this->escape($val['author']) ?></td> <td><?php echo $this->escape($val['title']) ?></td> </tr> <?phpendforeach; ?> </table> <?php else: ?> <p>There are no books to display.</p> <?phpendif;?>
  • 93. Using the ViewRenderer An action helper that is loaded by default Executes in the postDispatch() hook Examines the controller/action combination and automatically runs the proper view script IndexController::indexAction() /views/scripts/index/index.phtml
  • 94. View Helpers View helpers make your life easier Used to provide additional functionality similar to an action helper, but for the view Referenced via the $this object when in a view Loaded using a plugin loader Used to keep logic out of the view (very important) Try to limit views to if and foreach statements
  • 95. View Helpers Examples Easy translation integration echo $this->translate('Hello World'); Capturing JS so it can be output elsewhere <?php $this->headScript()->captureStart(); ?> alert('Hello World'); <?php $this->headScript()->captureEnd(); ?>
  • 96. View Helpers You can build your own! Does not need to implement any interface or abstract class Generally placed in /views/helpers (configurable) Must have a method name defined as the same name of the class My_Helper_Sendemail must have a method called sendemail(). class My_Helper_Sendemail { public function sendemail($to, $subject, $message) { // Haven't gotten to Zend_Mail yet :-) mail($to, $subject, $message); } }
  • 97. Using Partials Partials are used to render small, re-usable portions of the view Handled via a view helper Partial PartialLoop Very useful for any iterative functionality Arrays Zend_Db_Table_Rowset Anything implementing the Iterator interface
  • 98. The Model Unlike other frameworks it is any class that represents your data or business logic Could be a service object Could be a text file Could be an LDAP entry Could be a Zend_Db object
  • 99. Zend_Db Database abstraction layer (as opposed to access abstraction layer) Several different database vendors are supported Abstractions for common functionality such as select, insert, update, delete, limit, offset or transactions Connects to the database on demand Adapter instance is usually created via Zend_Db::factory() Integrated database profiling
  • 100. Zend_Db_Select Provides a vendor-independent mechanism for creating select statements Very useful, but be careful of the unintended consequences of abstraction $select->from('table') ->where('table_id = ?', $_GET[‘val']); Output: SELECT `table`.* FROM `table` WHERE (table_id = ?) Supports multiple join types, where, group by, order, etc.
  • 101. ORM Uses the Table/Row Data Gateway Design Patterns One class to represent the table One class to represent a row in the table
  • 102. ORM – The Table Table classes extend Zend_Db_Table_Abstract Handles references to other tables class Model_DbTable_Comment extends Zend_Db_Table_Abstract { protected $_name = 'comment'; protected $_rowClass = 'Model_Comment'; protected $_referenceMap = array( 'Content' => array( 'columns' => 'content_key', 'refTableClass' => 'Model_DbTable_Content', 'refColumns' => 'content_key' ), ); }
  • 103. ORM – The Row Model classes extend Zend_Db_Table_Row_Abstract class Model_City extends Zend_Db_Table_Row_Abstract { } Row data is accessed via a __get call Good idea to use getters and setters to access them (great for code completion)
  • 104. Fetching Data $dbTable = new Model_DbTable_Comment(); $comment = $dbTable->find($_GET['id']); $dbTable = new Model_DbTable_Comment(); $select = $dbTable->select() ->where('active = ?', $_GET['active']); $comment = $dbTable->fetchRow()->current();
  • 105. ORM - Relationships Retrieve an instance of the row class Call a wacked method call which calls __call() and figures out which db table object to load and query on. class Model_DbTable_Comment extends Zend_Db_Table_Abstract { protected $_name = 'comment'; protected $_rowClass = 'Model_Comment'; protected $_referenceMap = array( 'Content' => array( 'columns' => 'content_key', 'refTableClass' => 'Model_DbTable_Content', 'refColumns' => 'content_key' ), ); }
  • 106. Calling a related object $tabs = $comment ->findModel_DbTable_TagViaModel_DbTable_TagContent(); Write a getter that defines that in your model class Model_Content extends Esc_ModelAbstract { public function getTags() { return $this ->findModel_DbTable_TagViaModel_DbTable_TagContent() } }
  • 108. Unit Testing Why Unit Test? Simplify maintenance It defines expectations It describes behaviors identified by the application It tells us when new changes break existing code and behaviors
  • 109. Terms Unit The piece of code you are testing Test A piece of code that calls the piece of code you’re testing Assertion Validating return types or results of the test Code Coverage A report on which lines of code have been tested Used to determine additional tests that need to be written Continuous Integration The continuous application of quality control, i.e. unit tests
  • 110. Testing the model The easiest of all Test classes typically extend PHPUnit_Framework_TestCase
  • 111. Testing the controller Setting up the test Test class extends Zend_Test_PHPUnit_ControllerTestCase If testing Zend_Application make sure you add the bootstrap in the setUp() method Make sure you reset() your tests Response Request Layout Helper Broker
  • 112. Testing the controller You can test Routing (also good for checking authorization) Response codes Output (we’ll look at that next)
  • 113. Testing the view Best tested through the controller Define which HTML elements need to be present on the page and verify that they exist or have certain values Can be done using CSS Selectors Xpath Queries
  • 114. Zend_Layout Implements Two Step View pattern Same name as a dance in Texas, but that’s not important
  • 115. A little more advanced…
  • 116. Zend_Application Used for defining an application context Zend_Controller_Front just handled the brokering of the request Zend_Application handles Bootstrapping (dev/testing/staging/production) Creating the autoloader Dispatching Resource creation
  • 117. Bootstrapping Implements Zend_Application_Bootstrap_Bootstrapper Used to bootstrap (set up the environment) and then execute the request Most applications can simply extend Zend_Application_Bootstrap_Bootstrap This is what we will assume you are using
  • 118. Bootstrapping Resource methods Use the resource autoloader Zend_Application_Module_Autoloader placed in _initAutoload() Order Zend_Application::bootstrap() Bootstrap class instantiated Any methods starting with _init() are called and the return value is placed in a container Action retrieves the resource through calling getInvokeArg() and naming the resource
  • 119. Bootstrapping Bootstrap class is instantiated every time so DON’T put everything there (horrible for performance, PHP loves lazy loading) One option is to override hasResource() method in Bootstrap so that it instantiates a resource only when it is needed Best practice? Don’t know. Kevin’s practice? Yes. Therefore it is good
  • 120. Resources Pluggable pieces of functionality tied to the application Ties functionality directly in with the configuration Sample of existing plugins Cachemanager Db Log Frontcontroller Translate
  • 122. Service Theory Many services have a very similar execution flow Receive request Find class that can service the request Instantiate object that can handle the request Return result to client Why re-invent the wheel?
  • 123. Zend_Server Base component for several service-oriented components Primarily used for reflection and a standard interface Actual implementation is left to component
  • 124. Zend_*_Server Several components implement Zend_Server_Abstract Useful for standardized web service implementation foreach (glob(APPLICATION_PATH.'/mappers/*.php') as $dir) { $name = substr(basename($dir), 0, -4); $class = 'Mapper_' . $name; $serviceHandler->setClass($class, $name); } echo $serviceHandler->handle(); Using data mappers are your key to happiness $serviceHandler = new Zend_Json_Server(); $serviceHandler = new Zend_Amf_Server(); $serviceHandler = new Zend_Xml_Server();
  • 125. Writing Re-usable Models Write your application logic once, but use it in many different ways Why? MVC is only one consumer Can be called by job scripts, message systems, queues, etc. Service endpoints can act as consumers(Hint: JSON-RPC is a good way to feed your Ajax applications) 112
  • 126.
  • 127. The individual resources and units of work in your application
  • 128. E.g. user, team, backlog, sprint, etc.
  • 129. E.g., object relations, transactions, queries
  • 131. Public API of the application; i.e., the behaviors you wish to expose
  • 132.
  • 133.
  • 134. Allows easy re-use of your application via services
  • 135.
  • 137.
  • 138.
  • 141.
  • 142. Zend_Json Useful for encoding/decoding data $data = range(1, 20); echo Zend_Json::encode($data); meh Zend_Json_Server is neato JSON-RPC implementation Supported by Dojo Jquery (via plugin) Several more
  • 143. Zend_Json Server Side $serviceHandler = new Zend_Json_Server(); $serviceHandler->setClass('Peaks'); echo $serviceHandler->handle(); Client Side dojo.require("dojo.io.script"); dojo.require("dojo.rpc.JsonService"); dojo.addOnLoad(function(){ rpc = new dojo.rpc.JsonService("/json-rpc", "Peaks"); call = rpc["Peaks.getStates"]().addCallback( function(data) {/*todo*/}); });
  • 144. Zend_Amf AMF = Action Message Format Proprietary, Open Spec protocol developed by Adobe Used primarily for implementing a service that communicates with Flash applications Zend_Amf_Server extends Zend_Server_Abstract Works well with switching between JSON, XML-RPC AMF supports typed parameters and return values Setting up an AMF interface in Flash Builder/Zend Studio
  • 145. Zend_Service_Twitter Stupid easy Twitter access $twitter = new Zend_Service_Twitter( 'mytwitterusername', 'password‘ ); $response = $twitter->status->update( 'OSI Days Rocks!‘ );
  • 146. Zend_Service_Twitter Public API calls often don’t even require authentication $ts = new Zend_Service_Twitter_Search('json'); $res = $ts->search( $this->_search, array( 'since_id'=> (int)$id ) ); $text = array(); foreach ($res['results'] as $result) { $text[] = $result['text']; }
  • 148. What will ZF 2 be like? Goals Ease the learning curve Make extending the framework trivially simple Improve baseline performance of the framework Simplify maintenance of the framework Be an exemplar of PHP 5.3 usage Provide mechanisms for using just the parts of the framework needed
  • 149. What will ZF 2 be like? Roadmap Standardized Option Keys Exceptions. Each component will have it's own Exception interface Design By Contract Elimination of most singletons Create general-purpose, cross-functional components to reduce duplicate code Usage of new language features within plugin architectures, specifically __invoke() and closures
  • 150. What will ZF 2 be like? Roadmap (con’t) Autoload-only. Full use of Namespaces. goto. (usage of goto will be evaluated on a case-by-case basis)
  • 151. What will ZF 2 be like? Should you be thinking about ZF2? Not yet
  • 153. Follow us! Zend Technologies http://twitter.com/zend http://twitter.com/kpschrade (me!)
  • 154. Get this information and all the examples at eschrade.com…
  • 155.
  • 158. Deploy and scale large PHP applications
  • 159. Explore new technologies like NoSQL and Cloud Computing
  • 160. Learn how to effectively leverage Zend Framework and Zend Framework 2.0