Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Zend Framework 1.x$incontro[pugBO][7] = Introduction to Zend Framework   http://magni.me
whoami   •   Matteo Magni   •   @ilbonzo   •   https://github.com/ilbonzo   •   http://it.linkedin.com/in/matteomagni$inco...
Zend Framework 1.X   • Zend Framework is an open source, object oriented     web application framework for PHP 5. Zend    ...
Installation   • Register and download source   • Add to your include path        – sudo mv ~/ZendFramework­1.11.11/librar...
MVC$incontro[pugBO][7] = Introduction to Zend Framework   http://magni.me
Demo project for Layar   • http://layar.com/     Its mobile browser     allows users to find     various items based     u...
Create Project$incontro[pugBO][7] = Introduction to Zend Framework   http://magni.me
Config Apps       /application/configs/application.ini$incontro[pugBO][7] = Introduction to Zend Framework   http://magni.me
Bootstrap   /application/Bootstrap.php   class Bootstrap extends Zend_Application_Bootstrap_Bootstrap   {       protected ...
Layouts   • $ zf enable layout    •   /application/configs/application.ini        – resources.layout.layoutPath = APPLICAT...
ZF overview   • Models(db-     tables,objectmodels)   • Views(helpers,scripts,layouts)   • Controllers(actions,helpers)   ...
Namespace & Route   • All classes named for their folder     (e.g.Application_Model_Post in     application/models/post.ph...
Controller & Actions       $ zf create controller Point       $ zf create action view Point       $ zf create action add P...
Views e Actions   • Create views       /application/views/scripts/point/[action].phtml       esempio:       <br /><br />  ...
Database       /application/configs/application.ini       PostgreSQL DB       resources.db.adapter = PDO_PGSQL       resou...
Zend_Db       The Zend_Db_Table solution is an implementation of the       Table Data Gateway pattern. The solution also i...
DbTable - DbTableRow    $ zf create db­table Points points    $ zf create model Point   /application/models/Point.php   cl...
Form - Validation   $ zf create form Point   /application/forms/Point.php   class Application_Form_Point extends Zend_Form...
Controller – Form   /application/controllers/PointController.php           $form = new Application_Form_Point();          ...
Views - Form   /application/views/scripts/point/add.phtml   <?php   $this­>title = "Add new Point";   $this­>headTitle($th...
Models and Table                       Relationshipsclass Application_Model_DbTable_Points extends Zend_Db_Table_Abstract{...
Component Library     Zend_Acl   •     Zend_Amf   •     Zend_Application   •     Zend_Auth   •     Zend_Barcode   •     Ze...
Youtube       https://developers.google.com/youtube/2.0/developers_guide_php$incontro[pugBO][7] = Introduction to Zend Fra...
ZF & Drupal       http://drupal.org/project/zend  Its possible but Dries chose Symfony$incontro[pugBO][7] = Introduction t...
Questions?                           http://blog.ilbonzo.org                          http://twitter.com/ilbonzo$incontro[...
Upcoming SlideShare
Loading in …5
×

Introduction to Zend framework

2,036 views

Published on

$incontro['pugBO'][7] = 'Introduction to Zend Framework'

Introduction to Zend Framework 1.x for pugBO

Published in: Technology, Education
  • Be the first to comment

Introduction to Zend framework

  1. 1. Zend Framework 1.x$incontro[pugBO][7] = Introduction to Zend Framework http://magni.me
  2. 2. whoami • Matteo Magni • @ilbonzo • https://github.com/ilbonzo • http://it.linkedin.com/in/matteomagni$incontro[pugBO][7] = Introduction to Zend Framework http://magni.me
  3. 3. Zend Framework 1.X • Zend Framework is an open source, object oriented web application framework for PHP 5. Zend Framework is often called a component library, because it has many loosely coupled components that you can use more or less independently. • http://framework.zend.com/ • BSD license • Version 1.11$incontro[pugBO][7] = Introduction to Zend Framework http://magni.me
  4. 4. Installation • Register and download source • Add to your include path – sudo mv ~/ZendFramework­1.11.11/library/Zend/  /usr/share/php/Zend OR – sudo mv ~/ZendFramework­1.11.11/library/Zend/  [project]/library/Zend • Install bin tools – sudo mv ~/ZendFramework­1.11.11  /usr/share/php/ZendFramework – alias zf=/usr/share/php/ZendFramework/bin/zf.sh$incontro[pugBO][7] = Introduction to Zend Framework http://magni.me
  5. 5. MVC$incontro[pugBO][7] = Introduction to Zend Framework http://magni.me
  6. 6. Demo project for Layar • http://layar.com/ Its mobile browser allows users to find various items based upon augmented reality technology. • https://github.com/ilbonzo/Wade$incontro[pugBO][7] = Introduction to Zend Framework http://magni.me
  7. 7. Create Project$incontro[pugBO][7] = Introduction to Zend Framework http://magni.me
  8. 8. Config Apps /application/configs/application.ini$incontro[pugBO][7] = Introduction to Zend Framework http://magni.me
  9. 9. Bootstrap /application/Bootstrap.php class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {     protected function _initDoctype()     {         $this­>bootstrap(view);         $view = $this­>getResource(view);         $view­>doctype(HTML5);     }     ....... }$incontro[pugBO][7] = Introduction to Zend Framework http://magni.me
  10. 10. Layouts • $ zf enable layout  • /application/configs/application.ini – resources.layout.layoutPath = APPLICATION_PATH  "/layouts/scripts/" • Twitter Bootstrap http://twitter.github.com/bootstrap/ Other Layouts $this­>_helper­>layout­>setLayout(layout_other);$incontro[pugBO][7] = Introduction to Zend Framework http://magni.me
  11. 11. ZF overview • Models(db- tables,objectmodels) • Views(helpers,scripts,layouts) • Controllers(actions,helpers) • Forms$incontro[pugBO][7] = Introduction to Zend Framework http://magni.me
  12. 12. Namespace & Route • All classes named for their folder (e.g.Application_Model_Post in application/models/post.php) • Every Zend module is auto loaded when needed • Default controller/action is Index • URLformat: /<controller>/<action>$incontro[pugBO][7] = Introduction to Zend Framework http://magni.me
  13. 13. Controller & Actions $ zf create controller Point $ zf create action view Point $ zf create action add Point $ zf create action update Point $ zf create action delete Point create file /application/controllers/PointController.php class PointController extends Zend_Controller_Action {     public function init()     {         /* Initialize action controller here */     }     public function indexAction()    {        // action body    }$incontro[pugBO][7] = Introduction to Zend Framework  ... http://magni.me
  14. 14. Views e Actions • Create views /application/views/scripts/point/[action].phtml esempio: <br /><br /> <div id="view­content"> <p>View script for controller <b>Point</b> and  script/action name <b>add</b></p> </div>$incontro[pugBO][7] = Introduction to Zend Framework http://magni.me
  15. 15. Database /application/configs/application.ini PostgreSQL DB resources.db.adapter = PDO_PGSQL resources.db.params.host = localhost resources.db.params.username = postgres resources.db.params.password =  resources.db.params.dbname = wade$incontro[pugBO][7] = Introduction to Zend Framework http://magni.me
  16. 16. Zend_Db The Zend_Db_Table solution is an implementation of the Table Data Gateway pattern. The solution also includes a class that implements the Row Data Gateway pattern.$incontro[pugBO][7] = Introduction to Zend Framework http://magni.me
  17. 17. DbTable - DbTableRow $ zf create db­table Points points $ zf create model Point /application/models/Point.php class Application_Model_Point extends Zend_Db_Table_Row_Abstract {     function __get($key)     {         if (method_exists($this, $key)) {             return $this­>$key();         }         return parent::__get($key);     } }$incontro[pugBO][7] = Introduction to Zend Framework http://magni.me
  18. 18. Form - Validation $ zf create form Point /application/forms/Point.php class Application_Form_Point extends Zend_Form {     public function init()     {         $title = new Zend_Form_Element_Text(title);         $title­>setLabel(title)                 ­>setRequired(true)                 ­>addFilter(StripTags)                 ­>addFilter(StringTrim)                 ­>addValidator(NotEmpty);     } }$incontro[pugBO][7] = Introduction to Zend Framework http://magni.me
  19. 19. Controller – Form /application/controllers/PointController.php         $form = new Application_Form_Point();         $form­>submit­>setLabel(Add);         $this­>view­>form = $form;         if ($this­>getRequest()­>isPost()) {             $formData = $this­>getRequest()­>getPost();             if ($form­>isValid($formData)) {                 $title = $form­>getValue(title);                 ....                 $point = new Application_Model_DbTable_Points();                 $point­>addPoint($title, $footnote, $description, $lat, $lon,  $alt);                 $this­>_helper­>redirector(index);             } else {                 $form­>populate($formData);             }         }        $incontro[pugBO][7] = Introduction to Zend Framework http://magni.me
  20. 20. Views - Form /application/views/scripts/point/add.phtml <?php $this­>title = "Add new Point"; $this­>headTitle($this­>title); echo $this­>form ; ?>$incontro[pugBO][7] = Introduction to Zend Framework http://magni.me
  21. 21. Models and Table Relationshipsclass Application_Model_DbTable_Points extends Zend_Db_Table_Abstract{      protected $_dependentTables = array(Application_Model_DbTable_Actions);....class Application_Model_DbTable_Actions extends Zend_Db_Table_Abstract{    protected $_name = actions;    protected $_rowClass = Application_Model_Action;    protected $_primary = id;        protected $_referenceMap = array(        Application_Model_DbTable_Points => array(         columns => array(point_id),            refTableClass => Application_Model_DbTable_Points,            refColumns => array(id)        ),$incontro[pugBO][7] = Introduction to Zend Framework http://magni.me
  22. 22. Component Library Zend_Acl • Zend_Amf • Zend_Application • Zend_Auth • Zend_Barcode • Zend_Cache • Zend_Captcha • -------- • Zend_Config • Zend_Config_Writer • Zend_Controller • Zend_Currency • Zend_Date • Zend_Db • ---------- • ZendX_JQuery •$incontro[pugBO][7] = Introduction to Zend Framework http://magni.me
  23. 23. Youtube https://developers.google.com/youtube/2.0/developers_guide_php$incontro[pugBO][7] = Introduction to Zend Framework http://magni.me
  24. 24. ZF & Drupal http://drupal.org/project/zend Its possible but Dries chose Symfony$incontro[pugBO][7] = Introduction to Zend Framework http://magni.me
  25. 25. Questions? http://blog.ilbonzo.org http://twitter.com/ilbonzo$incontro[pugBO][7] = Introduction to Zend Framework http://magni.me

×