zend framework quick start faheem abbas software engineer
TRANSCRIPT
Zend Framework Zend Framework Quick startQuick start
Faheem Abbas Faheem Abbas
Software engineerSoftware 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
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)))
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.
Directory structureDirectory structure
Bootstrap (index.php)Bootstrap (index.php)
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(){{}}
}}?>?>
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>
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;}}
} } ?>?>
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;
}}}}
?>?>
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;
?>?>
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