Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Get started with Zend Framework

Get started with Zend Framework

Kick start with zend framework in an easy way.

Mohammad Shoriful Islam Ronju

February 26, 2012
Tweet

Other Decks in Programming

Transcript

  1. Ge#ng  Up  &  Running  with       Saidur  Rahman

     Bijon   Shoriful  Islam  Ronju  
  2. Agenda   •  Overview   •  MVC   •  Components

      •  Environment  setup   •  Your  first  Zend  Framework  project   •  Resources   •  QA  
  3. Why  Zend  Framework   • Maintain  by  PHP  Company   • Open

     Source   • Flexible  Architecture     •   ZF  CerEficaEon       • Partner  with  
  4. Environment  Setup   •  Requirements   1.  PHP  5.x  

    2.  Web  server  with  mod_rewrite  enabled  
  5. Environment  Setup  (ConEnued…)   •  Zend  tool  setup  (Ubuntu  way)

      ; include_path=${include_path} “:/path/to/libzend- framework-php” // uncomment in /etc/php5/conf.d/zend- framework.ini sudo  apt-­‐get  install  zend-­‐framework  
  6. Environment Setup (Continued…) •  Zend tool setup verification zf  show

     version    Zend  Framework  Version:  1.11.10  
  7. Create  Virtual  host   <VirtualHost *:80> ServerName local.sitename.com DocumentRoot /var/www/zf-project/public

    <Directory "/var/www/zf-project/public"> AllowOverride All </Directory> </VirtualHost>
  8. ConnecEng  to  database   resources.db.adapter = "Pdo_Mysql” resources.db.params.host = ”HostName"

    resources.db.params.username = ”UserName" resources.db.params.password = ”Password" resources.db.params.dbname = ”DbName"
  9. Controller   <?php class AlbumController extends Zend_Controller_Action{ public function init(){

    /* Initialize action controller here */ } public function indexAction(){ /* Your code goes here */ } }
  10. Model   <?php class Application_Model_Albums extends Zend_Db_Table_Abstract { protected $_name

    = 'albums'; public function fName() { /* Your code goes here */ } }
  11. Crud  operaEon   public function addAlbum($data) { $this->insert($data); } public

    function updateAlbum($data, $where) { $this->update($data, $where); } public function deleteAlbum($where) { $this->delete($where); }
  12. Zend  Frameworks  Gems  J   1.  Google 2.  Amazon 3. 

    Flickr 4.  Yahoo 5.  More…. •  Web  services  
  13. Zend  web  service  (flickr)   public function flickrAction(){ $flickr =

    new Zend_Service_Flickr(’YourAPIKey'); $this->view->results = $flickr->tagSearch('worldcup’); }
  14. Zend  web  service  (flickr)   <ul> <?php foreach ($this->results as

    $result){ "$photo = $result->Square; ?> "<li><a href="<?php echo $photo->ClickUri ?>"> " "<img src="<?php echo $photo->uri ?>" alt="image"/> " </a> "</li> <?php } ?> </ul>