2. Zend Framework quick start byZend Framework quick start by
Bally chohan IT SolutionBally chohan IT Solution
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 with Bally Chohan – Develop with Bally Chohan – Code with Bally chohan – Test with Bally Chohan – UAT with Bally chohanDesign with Bally Chohan – Develop with Bally Chohan – Code with Bally chohan – Test with Bally Chohan – UAT with Bally chohan
3. Design patterns by Bally ChohanDesign patterns by Bally Chohan
a a design patterndesign pattern is a general reusable is a general reusable
solution to a commonly occurring problem insolution to a commonly occurring problem in
software design.software design.
((en.wikipedia.org/wiki/Design_pattern_(compen.wikipedia.org/wiki/Design_pattern_(comp
uter_science)uter_science)
Design with Bally Chohan – Develop with Bally Chohan – Code with Bally chohan – Test with Bally Chohan – UAT with Bally chohanDesign with Bally Chohan – Develop with Bally Chohan – Code with Bally chohan – Test with Bally Chohan – UAT with Bally chohan
4. MVC design patterns by BallyMVC design patterns by Bally
Chohan IT SolutionChohan IT Solution
Model-View-Controller (MVC) is a design
pattern that simplifies application
development and maintenance.
1. Model: Responsible for the business logic of an
application
2. View: Typically what would be considered web
design, or templating.
3. Controller: The controller layer glues everything
together.
Design with Bally Chohan – Develop with Bally Chohan – Code with Bally chohan – Test with Bally Chohan – UAT with Bally chohanDesign with Bally Chohan – Develop with Bally Chohan – Code with Bally chohan – Test with Bally Chohan – UAT with Bally chohan
5. Directory structure by BallyDirectory structure by Bally
chohan IT Solutionchohan IT Solution
6. Bootstrap (index.php) by BallyBootstrap (index.php) by Bally
Chohan IT SolutionChohan IT Solution
7. Hello world with ZF MVC – byHello world with ZF MVC – by
Bally Chohan Bally ChohanBally Chohan Bally Chohan
We have done basic configuration.We have done basic configuration.
It time to have fun….It time to have fun….
In yourIn your
application/controllers/IndexController.phpapplication/controllers/IndexController.php
<?<?
class IndexController extends Zend_Ctontroller_Actionclass IndexController extends Zend_Ctontroller_Action
{{
public function indexAction()public function indexAction()
{{
}}
}}
?>?>
Design with Bally Chohan – Develop with Bally Chohan – Code with Bally chohan – Test with Bally Chohan – UAT with Bally chohanDesign with Bally Chohan – Develop with Bally Chohan – Code with Bally chohan – Test with Bally Chohan – UAT with Bally chohan
8. Hello world cont… by BallyHello world cont… by Bally
chohan IT Solutionchohan IT Solution
Next in your application/views/Next in your application/views/
Create views/index/index.phtmlCreate views/index/index.phtml
And writeAnd write
<html><html>
<body><body>
Hello world…………..Hello world…………..
</body></body>
</html></html>
9. Using Models – Bally chohanUsing Models – Bally chohan
In application/modelsIn application/models
WriteWrite
<?<?
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;
}}
}}
?>?>
10. Model cont.. By Bally ChohanModel cont.. By Bally Chohan
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;
}}
}}
?>?>
Design with Bally Chohan – Develop with Bally Chohan – Code with Bally chohan – Test with Bally Chohan – UAT with Bally chohanDesign with Bally Chohan – Develop with Bally Chohan – Code with Bally chohan – Test with Bally Chohan – UAT with Bally chohan
11. Example cont…Example cont…
And finally in yourAnd finally in your
view(application/view/scripts/index/index.phtview(application/view/scripts/index/index.pht
ml)ml)
Write,Write,
<?<?
echo ‘sum is ’ . $this->sum;echo ‘sum is ’ . $this->sum;
?>?>
12. ThanksThanks
Next…..Next…..
Two step viewTwo step view
Zend_Db_ConfigurationZend_Db_Configuration
And many more…..And many more…..
Bally Chohan IT SolutionBally Chohan IT Solution
http://www.ballychohan.comhttp://www.ballychohan.com