You are on page 1of 34

Getting Up & Running with

Agenda Overview MVC

Components
Environment setup Your first Zend Framework project Resources QA

What is framework ?
Toolbox
Blueprint

Skeleton

Why Zend Framework

Maintain by PHP Company

Open Source
Flexible Architecture ZF Certification Partner with

Zend Framework Architecture


MVC design pattern

Front Controller pattern


Component Based

Loosely couple

Zend Components

Zend_Validate

Zend_Auth
Zend_Acl
ZEND_FORM

Zend_Session

Zend web services Components

ZEND_FEED ZEND_GDATA

Environment Setup

Requirements
1. 2. PHP 5.x Web server with mod_rewrite enabled

Environment Setup (Continued)


Zend tool setup (Ubuntu way) sudo apt-get install zend-framework ; include_path=${include_path} :/path/to/libzendframework-php // uncomment in /etc/php5/conf.d/zendframework.ini

Environment Setup (Continued)


Zend tool setup (Windows way)

Environment Setup (Continued)

Environment Setup (Continued)

Environment Setup (Continued)

Environment Setup (Continued)

Environment Setup (Continued)


Zend tool setup verification

zf show version
Zend Framework Version: 1.11.10

Your first Zend Framework project

zf create project {project-name}

Your first Zend Framework project

Project structure

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>

Tada!

Connecting 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"

Lets have a CRUD operation

Create Retrieve Update Delete

Controller

zf create controller {name}

Controller
<?php

class AlbumController extends Zend_Controller_Action{


public function init(){
/* Initialize action controller here */

} public function indexAction(){


/* Your code goes here */

} }

Model

zf create model {model-name}

Model
<?php class Application_Model_Albums extends Zend_Db_Table_Abstract { protected $_name = 'albums'; public function fName() {
/* Your code goes here */

} }

Crud operation
public function addAlbum($data) { $this->insert($data); } public function updateAlbum($data, $where) { $this->update($data, $where); } public function deleteAlbum($where) { $this->delete($where); }

Zend Frameworks Gems

Web services
1. 2. 3. 4. 5. Google Amazon Flickr Yahoo More.

Zend web service (flickr)

Zend web service (flickr)

public function flickrAction(){ $flickr = new Zend_Service_Flickr(YourAPIKey'); $this->view->results = $flickr->tagSearch('worldcup); }

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>

Resources

http://akrabat.com/zend-framework-tutorial/ http://net.tutsplus.com/tutorials/php/zend-framework-from-scratch/ http://goo.gl/fQLL6

Who we are

Saidur Rahman Bijon @somewherein

Shoriful Islam Ronju @leevio

Questions & Answers

Any Question?