SlideShare a Scribd company logo
PHP Frameworks Using PHP framework for development process
“ A software framework, in computer programming, is an abstraction in which  common code providing generic functionality  can be selectively overridden or specialized by user code providing specific functionality. Frameworks are a special case of software libraries in that they are  reusable abstractions of code  wrapped in a well-defined Application programming interface (API), yet they contain some key distinguishing features that separate them from normal libraries. ”
Save times Unify Development Process Reusable Modularity Scalable Software Easy Maintenance Enterprise Softwares
 
Maintain by Zend - The PHP Company Partners: Adobe, Google, IBM, Microsoft Open source Large community Good documents
MVC Framework Component base framework Tons of components Require PHP 5.2.x or higher
 
Controller Accept Request Call Model Pass model data to View Model Process business logic Return result to Controller  View Receive result from Controller Display data Call model (optional)
Front  Controller Action Controller Component Library Data Internationalization PDF Database JSON Date Translate Locale Webservices SOAP Amazon Google Core Log Cache ACL Plugins View Edit Del HTTP Request
Accept HTTP Request Routing Call Action Controller Response to client
Find the target action base on request URL Standard router: http: //example/news   Module = news http: //example/foo   In case of “foo” module does not exists: Module= Default Module, Controller = foo http: //example/blog/archive   Module = Blog, Controller = archive http: //example/blog/archive/list Module = Blog, Controller = Archive, Action = List http: //example/blog/archive/list/sort/alpha/dir/desc Module = Blog, Controller = Archive, Action = List Params: sort = alpha, dir=desc
<?php /** * Index Controller */ class  IndexController  extends  Zend_Controller_Action { /** * Index Action */ public function  indexAction() { // action body } }
Zend_Db_Adapter IBM DB2, MySQL, SQL Server, Oracle, PostgreSQL, SQLite, Firebird Zend_Db_Statement Zend_Db_Profiler Zend_Db_Select Zend_Db_Table Zend_Db_Table_Row Zend_Db_Table_Rowset Zend_Db_Table Relationships Zend_Db_Table_Definition
<?php $params  = array( ' host ' => ' 127.0.0.1 ', ' username ' => ' webuser ', ' password ' => ’ ******* ', ' dbname ' => ' test ', ); $db  =  Zend_Db::factory (' Pdo_Mysql ',  $params ); $sql  = ‘ SELECT * FROM users ’; $rows  =  $db ->fetchAll( $sql );
<?php $select = $db -> select ()                   -> from (‘ users ’,  array (‘username’, ‘email’))                        -> where (‘ username = ? ’,  $username ) ; //Same as: // SELECT username, email FROM users // WHERE username = ‘…’ $user  =  $db -> fetchRow ( $select );
<?php class  Users  extends  Zend_Db_Table_Abstract { protected  $_name  = ' users '; protected  $_primaryKey  = ' user_id '; } //Insert $user  =  new  Users (); $user -> insert ( array ( ‘ username ’ => ‘ cusc ’ ‘ name ’ => ‘ CUSC Software ’, ‘ email ’ => ‘ [email_address] ’ ));
<?php //Update $user  =  new  Users (); $data  =  array ( ‘ email ’ => ‘ [email_address] ’ ); $user -> update ( $data , ‘ user_id = 1234 ’); //Delete row $user -> delete (‘ user_id = 1234 ’);
<?php //Find rows by primary key $user  =  new  Users (); $rows  =  $user -> find (1234); //Find by conditions $select  =  $user -> select ()                           -> where (“ email LIKE ‘%?’ ”, ‘musical .vn ’); $rows  =  $user -> fetchAll ( $select );
Scripts (templates) PHP-based script templates to present data Should contain only display logic, not business logic Default naming: “actionname.phtml”  Helpers Classes and methods that provide reusable view functionality Examples of built in view helpers: escape(), formText(), partial(), partialLoop(), headTitle() Write your own, too Layout Define application/page layout Using Two Step View pattern Placeholders
<?php /** * Index Controller */ class  IndexController  extends  Zend_Controller_Action { /** * Index Action */ public function  indexAction() { $this -> view -> name  = ‘ Dream Team ’; } }
<?php //index.phtml < h1 ><?php  echo  $this -> escape ( $this -> name ); ?></ h1 >
Flexible solution for building forms Create by PHP code, put it in model class Or create in configuration file Validation support Auto restore input values when error occurs. Using decorator for output form elements
class  Admin_Form_Account  extends  Zend_Form { public function  init()  { parent :: init (); $this -> setAction (' /admin/account/createPost '); $this -> addElement ( $this -> createElement (' text ', ' username ',  array ( ' required ' => true, ' label '       => ' Username ', ))); $this -> addElement ( $this -> createElement (' text ', ' name ',  array (            ' required ' => true,            ' label '       => ' Name ', ))); $this -> addElement ( $this -> createElement (' text ', ' email ',  array (            ' required ' => true,            ' label ' => ' Email ', ))); $this -> addElement ( $this -> createElement (' password ', ' password ',  array (            ' required ' => true,            ' label ' => ' Lastname ', ))); $this -> addElement (' submit ', ' Submit '); } }
<?php class  Admin_Account_Controller  extends  Zend_Controller_Action { public function  formAction() {            $form  = new  Admin_Form_Account ();            $this -> view -> form  =  $form ; } public function  createPostAction() {            $form  = new  Admin_Form_Account ();            if  (! $form -> isValid ( $this -> getRequest ()-> getPost ())) {                     $this -> view -> form  =  $form ;                     $this -> render (’ form ');            }  else  {                     $this -> _forward (’ success ');            } } }
Alnum Alpha Barcode Between CreditCard Ccnum Date Db_RecordExists Digits EmailAddress Float GreaterThan Hex Hostname Iban Identical InArray Int Ip Isbn LessThan NotEmpty PostCode Regex StringLength
class  Admin_Form_Account  extends  Zend_Form { public function  init()  {         parent :: init ();         $this -> addElement ( $this -> createElement (' text ', ' email ',  array (                 ' required '   => true,                 ' label '         => ' Email ',                 ' validators ' =>  array (' emailaddress '),           ))); } }
Main website:  http://framework.zend.com Quick Start:  http://framework.zend.com/manual/en/learning.quickstart.intro.html Manual:  http://framework.zend.com/manual/manual
Create Module Create Controller, Action Create Layout, View Create Form Update data

More Related Content

PDF
Error Reporting in ZF2: form messages, custom error pages, logging
PPT
Zend framework 04 - forms
PDF
Moving a high traffic ZF1 Enterprise Application to SF2 - Lessons learned
PDF
Dealing With Legacy PHP Applications
PPTX
I Love codeigniter, You?
PPS
Implementing access control with zend framework
PDF
Disregard Inputs, Acquire Zend_Form
ODP
Creating fast, dynamic ACLs in Zend Framework (Zend Webinar)
Error Reporting in ZF2: form messages, custom error pages, logging
Zend framework 04 - forms
Moving a high traffic ZF1 Enterprise Application to SF2 - Lessons learned
Dealing With Legacy PHP Applications
I Love codeigniter, You?
Implementing access control with zend framework
Disregard Inputs, Acquire Zend_Form
Creating fast, dynamic ACLs in Zend Framework (Zend Webinar)

What's hot (20)

ODP
Creating fast, dynamic ACLs in Zend Framework
PDF
Why is crud a bad idea - focus on real scenarios
PPT
What's New in ZF 1.10
PPT
Zend Framework
PPT
P H P Part I I, By Kian
PDF
Crafting [Better] API Clients
PPS
Php Security3895
PDF
Refactoring using Codeception
PPTX
SADI in Perl - Protege Plugin Tutorial (fixed Aug 24, 2011)
ODP
Concern of Web Application Security
KEY
PHP security audits
KEY
Geek Moot '09 -- Smarty 101
PPT
Django Forms: Best Practices, Tips, Tricks
KEY
Unit testing zend framework apps
ODP
Into to DBI with DBD::Oracle
PDF
Meet Magento Sweden - Magento 2 Layout and Code Compilation for Performance
PDF
PHPSpec - the only Design Tool you need - 4Developers
PDF
Learning To Run - XPages for Lotus Notes Client Developers
ODP
Zend Framework 1.9 Setup & Using Zend_Tool
PDF
Sorting arrays in PHP
Creating fast, dynamic ACLs in Zend Framework
Why is crud a bad idea - focus on real scenarios
What's New in ZF 1.10
Zend Framework
P H P Part I I, By Kian
Crafting [Better] API Clients
Php Security3895
Refactoring using Codeception
SADI in Perl - Protege Plugin Tutorial (fixed Aug 24, 2011)
Concern of Web Application Security
PHP security audits
Geek Moot '09 -- Smarty 101
Django Forms: Best Practices, Tips, Tricks
Unit testing zend framework apps
Into to DBI with DBD::Oracle
Meet Magento Sweden - Magento 2 Layout and Code Compilation for Performance
PHPSpec - the only Design Tool you need - 4Developers
Learning To Run - XPages for Lotus Notes Client Developers
Zend Framework 1.9 Setup & Using Zend_Tool
Sorting arrays in PHP
Ad

Similar to Framework (20)

PPTX
Zend framework
ODP
Zend_Form to the Rescue - A Brief Introduction to Zend_Form
PPTX
My Very First Zf App Part One
KEY
Unit testing with zend framework PHPBenelux
PDF
Unit testing with zend framework tek11
KEY
PDF
Add edit delete in Codeigniter in PHP
PPT
Getting Started with Zend Framework
PDF
Hebrew, Introduction to Zend Controller And new technique
PPT
Introduction to Zend Framework
ODP
Codegnitorppt
PDF
php-and-zend-framework-getting-started
PDF
PDF
php-and-zend-framework-getting-started
PDF
php-and-zend-framework-getting-started
PDF
php-and-zend-framework-getting-started
PDF
Intro To Mvc Development In Php
PPT
Zend - Installation And Sample Project Creation
ODP
Introduction to Zend Framework
Zend framework
Zend_Form to the Rescue - A Brief Introduction to Zend_Form
My Very First Zf App Part One
Unit testing with zend framework PHPBenelux
Unit testing with zend framework tek11
Add edit delete in Codeigniter in PHP
Getting Started with Zend Framework
Hebrew, Introduction to Zend Controller And new technique
Introduction to Zend Framework
Codegnitorppt
php-and-zend-framework-getting-started
php-and-zend-framework-getting-started
php-and-zend-framework-getting-started
php-and-zend-framework-getting-started
Intro To Mvc Development In Php
Zend - Installation And Sample Project Creation
Introduction to Zend Framework
Ad

Recently uploaded (20)

PDF
A novel scalable deep ensemble learning framework for big data classification...
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
Hindi spoken digit analysis for native and non-native speakers
PPTX
A Presentation on Artificial Intelligence
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPTX
Tartificialntelligence_presentation.pptx
PDF
Heart disease approach using modified random forest and particle swarm optimi...
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Getting Started with Data Integration: FME Form 101
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PPTX
Chapter 5: Probability Theory and Statistics
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PPTX
A Presentation on Touch Screen Technology
PDF
WOOl fibre morphology and structure.pdf for textiles
PPTX
1. Introduction to Computer Programming.pptx
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
A novel scalable deep ensemble learning framework for big data classification...
1 - Historical Antecedents, Social Consideration.pdf
Hindi spoken digit analysis for native and non-native speakers
A Presentation on Artificial Intelligence
A comparative analysis of optical character recognition models for extracting...
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Tartificialntelligence_presentation.pptx
Heart disease approach using modified random forest and particle swarm optimi...
Programs and apps: productivity, graphics, security and other tools
Getting Started with Data Integration: FME Form 101
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
Chapter 5: Probability Theory and Statistics
Univ-Connecticut-ChatGPT-Presentaion.pdf
A Presentation on Touch Screen Technology
WOOl fibre morphology and structure.pdf for textiles
1. Introduction to Computer Programming.pptx
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
From MVP to Full-Scale Product A Startup’s Software Journey.pdf

Framework

  • 1. PHP Frameworks Using PHP framework for development process
  • 2. “ A software framework, in computer programming, is an abstraction in which  common code providing generic functionality  can be selectively overridden or specialized by user code providing specific functionality. Frameworks are a special case of software libraries in that they are  reusable abstractions of code  wrapped in a well-defined Application programming interface (API), yet they contain some key distinguishing features that separate them from normal libraries. ”
  • 3. Save times Unify Development Process Reusable Modularity Scalable Software Easy Maintenance Enterprise Softwares
  • 4.  
  • 5. Maintain by Zend - The PHP Company Partners: Adobe, Google, IBM, Microsoft Open source Large community Good documents
  • 6. MVC Framework Component base framework Tons of components Require PHP 5.2.x or higher
  • 7.  
  • 8. Controller Accept Request Call Model Pass model data to View Model Process business logic Return result to Controller View Receive result from Controller Display data Call model (optional)
  • 9. Front Controller Action Controller Component Library Data Internationalization PDF Database JSON Date Translate Locale Webservices SOAP Amazon Google Core Log Cache ACL Plugins View Edit Del HTTP Request
  • 10. Accept HTTP Request Routing Call Action Controller Response to client
  • 11. Find the target action base on request URL Standard router: http: //example/news Module = news http: //example/foo In case of “foo” module does not exists: Module= Default Module, Controller = foo http: //example/blog/archive Module = Blog, Controller = archive http: //example/blog/archive/list Module = Blog, Controller = Archive, Action = List http: //example/blog/archive/list/sort/alpha/dir/desc Module = Blog, Controller = Archive, Action = List Params: sort = alpha, dir=desc
  • 12. <?php /** * Index Controller */ class IndexController extends Zend_Controller_Action { /** * Index Action */ public function indexAction() { // action body } }
  • 13. Zend_Db_Adapter IBM DB2, MySQL, SQL Server, Oracle, PostgreSQL, SQLite, Firebird Zend_Db_Statement Zend_Db_Profiler Zend_Db_Select Zend_Db_Table Zend_Db_Table_Row Zend_Db_Table_Rowset Zend_Db_Table Relationships Zend_Db_Table_Definition
  • 14. <?php $params = array( ' host ' => ' 127.0.0.1 ', ' username ' => ' webuser ', ' password ' => ’ ******* ', ' dbname ' => ' test ', ); $db = Zend_Db::factory (' Pdo_Mysql ', $params ); $sql = ‘ SELECT * FROM users ’; $rows = $db ->fetchAll( $sql );
  • 15. <?php $select = $db -> select ()                   -> from (‘ users ’,  array (‘username’, ‘email’))                       -> where (‘ username = ? ’, $username ) ; //Same as: // SELECT username, email FROM users // WHERE username = ‘…’ $user = $db -> fetchRow ( $select );
  • 16. <?php class Users extends Zend_Db_Table_Abstract { protected $_name = ' users '; protected $_primaryKey = ' user_id '; } //Insert $user = new Users (); $user -> insert ( array ( ‘ username ’ => ‘ cusc ’ ‘ name ’ => ‘ CUSC Software ’, ‘ email ’ => ‘ [email_address] ’ ));
  • 17. <?php //Update $user = new Users (); $data = array ( ‘ email ’ => ‘ [email_address] ’ ); $user -> update ( $data , ‘ user_id = 1234 ’); //Delete row $user -> delete (‘ user_id = 1234 ’);
  • 18. <?php //Find rows by primary key $user = new Users (); $rows = $user -> find (1234); //Find by conditions $select = $user -> select ()                           -> where (“ email LIKE ‘%?’ ”, ‘musical .vn ’); $rows = $user -> fetchAll ( $select );
  • 19. Scripts (templates) PHP-based script templates to present data Should contain only display logic, not business logic Default naming: “actionname.phtml” Helpers Classes and methods that provide reusable view functionality Examples of built in view helpers: escape(), formText(), partial(), partialLoop(), headTitle() Write your own, too Layout Define application/page layout Using Two Step View pattern Placeholders
  • 20. <?php /** * Index Controller */ class IndexController extends Zend_Controller_Action { /** * Index Action */ public function indexAction() { $this -> view -> name = ‘ Dream Team ’; } }
  • 21. <?php //index.phtml < h1 ><?php echo $this -> escape ( $this -> name ); ?></ h1 >
  • 22. Flexible solution for building forms Create by PHP code, put it in model class Or create in configuration file Validation support Auto restore input values when error occurs. Using decorator for output form elements
  • 23. class Admin_Form_Account extends Zend_Form { public function init()  { parent :: init (); $this -> setAction (' /admin/account/createPost '); $this -> addElement ( $this -> createElement (' text ', ' username ', array ( ' required ' => true, ' label '       => ' Username ', ))); $this -> addElement ( $this -> createElement (' text ', ' name ', array (           ' required ' => true,           ' label '       => ' Name ', ))); $this -> addElement ( $this -> createElement (' text ', ' email ', array (           ' required ' => true,           ' label ' => ' Email ', ))); $this -> addElement ( $this -> createElement (' password ', ' password ', array (           ' required ' => true,           ' label ' => ' Lastname ', ))); $this -> addElement (' submit ', ' Submit '); } }
  • 24. <?php class Admin_Account_Controller extends Zend_Controller_Action { public function formAction() {           $form = new Admin_Form_Account ();           $this -> view -> form = $form ; } public function createPostAction() {           $form = new Admin_Form_Account ();           if (! $form -> isValid ( $this -> getRequest ()-> getPost ())) {                     $this -> view -> form = $form ;                     $this -> render (’ form ');           } else {                     $this -> _forward (’ success ');           } } }
  • 25. Alnum Alpha Barcode Between CreditCard Ccnum Date Db_RecordExists Digits EmailAddress Float GreaterThan Hex Hostname Iban Identical InArray Int Ip Isbn LessThan NotEmpty PostCode Regex StringLength
  • 26. class Admin_Form_Account extends Zend_Form { public function init()  {         parent :: init ();         $this -> addElement ( $this -> createElement (' text ', ' email ', array (                 ' required '   => true,                 ' label '         => ' Email ',                 ' validators ' => array (' emailaddress '),           ))); } }
  • 27. Main website: http://framework.zend.com Quick Start: http://framework.zend.com/manual/en/learning.quickstart.intro.html Manual: http://framework.zend.com/manual/manual
  • 28. Create Module Create Controller, Action Create Layout, View Create Form Update data