zend framework quick start faheem abbas software engineer

12
Zend Framework Zend Framework Quick start Quick start Faheem Abbas Faheem Abbas Software engineer Software engineer

Upload: marian-barker

Post on 13-Jan-2016

215 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Zend Framework Quick start Faheem Abbas Software engineer

Zend Framework Zend Framework Quick startQuick start

Faheem Abbas Faheem Abbas

Software engineerSoftware engineer

Page 2: Zend Framework Quick start Faheem Abbas Software engineer

Zend Framework quick startZend Framework quick start

1.1. Design patternsDesign patterns

2.2. MVC design patternsMVC design patterns

3.3. Directory StructureDirectory Structure

4.4. BootstrapBootstrap

5.5. Hello world exampleHello world example

Page 3: Zend Framework Quick start Faheem Abbas Software engineer

Design patternsDesign patterns

  a a design patterndesign pattern is a general reusable  is a general reusable solution to a commonly occurring solution to a commonly occurring problem in software design.problem in software design.

((en.wikipedia.org/en.wikipedia.org/wiki/wiki/Design_pattern_(computer_science)Design_pattern_(computer_science)))

Page 4: Zend Framework Quick start Faheem Abbas Software engineer

MVC design patternsMVC design patterns

Model-View-Controller (MVC) is a designpattern that simplifies applicationdevelopment and maintenance.1. Model: Responsible for the business logic

of an application2. View: Typically what would be considered

web design, or templating.3. Controller: The controller layer glues

everything together.

Page 5: Zend Framework Quick start Faheem Abbas Software engineer

Directory structureDirectory structure

Page 6: Zend Framework Quick start Faheem Abbas Software engineer

Bootstrap (index.php)Bootstrap (index.php)

Page 7: Zend Framework Quick start Faheem Abbas Software engineer

Hello world with ZF MVCHello world with ZF MVC

We have done basic configuration.We have done basic configuration.It time to have fun….It time to have fun….In your In your

application/controllers/IndexController.phapplication/controllers/IndexController.phpp

<?<?class IndexController extends Zend_Ctontroller_Actionclass IndexController extends Zend_Ctontroller_Action{{

public function indexAction()public function indexAction(){{}}

}}?>?>

Page 8: Zend Framework Quick start Faheem Abbas Software engineer

Hello world cont…Hello world cont…

Next in your application/views/Next in your application/views/Create views/index/index.phtmlCreate views/index/index.phtmlAnd writeAnd write<html><html><body><body>Hello world…………..Hello world…………..</body></body></html></html>

Page 9: Zend Framework Quick start Faheem Abbas Software engineer

Using ModelsUsing Models

In application/modelsIn application/modelsWriteWrite<?<?class Mathclass Math{{

public function __construct()public function __construct(){{}}public function sum($val1,$val2)public function sum($val1,$val2){{

return $val1 + $val2;return $val1 + $val2;}}

} } ?>?>

Page 10: Zend Framework Quick start Faheem Abbas Software engineer

Model cont..Model cont..

Now in controller, writeNow in controller, write<?<?

class IndexController extends Zend_Ctontroller Actionclass IndexController extends Zend_Ctontroller Action{{

public function indexAction()public function indexAction(){{

$math = new Math();$math = new Math();$sum = $math->sum(5,10);$sum = $math->sum(5,10);$this->view->sum=$sum;$this->view->sum=$sum;

}}}}

?>?>

Page 11: Zend Framework Quick start Faheem Abbas Software engineer

Example cont…Example cont…

And finally in your And finally in your view(application/view/scripts/index/indview(application/view/scripts/index/index.phtml)ex.phtml)

Write,Write,

<?<?

echo ‘sum is ’ . $this->sum;echo ‘sum is ’ . $this->sum;

?>?>

Page 12: Zend Framework Quick start Faheem Abbas Software engineer

ThanksThanks

Next…..Next…..

Two step viewTwo step view

Zend_Db_ConfigurationZend_Db_Configuration

And many more…..And many more…..

Faheem AbbasFaheem Abbas

Software Software engineerengineer