13. class Person {
public $db;
public function __construct($dbConfig) {
$this->db = new DbAdapter($dbConfig);
}
}
$person = new Person($dbConfig);
$person->...
14. class Person {
public $db;
public function setDb(DbAdapter $dbAdapter)
{
$this->db = $dbAdapter;
}
}
$person = new Person();
$person->setDb(new DbAdapter($dbConfig));
$person->...
15. Dependency Injection
貼叩dn辿 intern鱈 z叩vislosti
snadnj邸鱈 testov叩n鱈
Konec e邸en鱈 jak to tam ped叩m?
(skon鱈 vt邸inou na Zend_Registry)
istj邸鱈 k坦d
16. ZendDi
Nap鱈 cel箪m frameworkem
nap. tah叩n鱈 z叩vislost鱈 do controlleru
Nen鱈 poteba new, sta鱈 settery a ono
se to automagicky napln鱈
27. Request/Response
sestaveny pesn podle RFC
minit鱈dy na jednotliv辿 elementy
HTTP (Location, ContentType, etc)
pos鱈laj鱈 se v r叩mci MVC event哲
Response agreguje v箪sledky
31. 永鉛顎乙庄稼霞/堰艶鉛沿艶姻霞/
sjednocen辿 interface Pluggable
zjednodu邸en辿 na鱈t叩n鱈 (z pohledu
programov辿 slo転itosti)
trochu slo転itj邸鱈 na rozjet鱈 pro v箪voj叩e
(explicitn se registruj鱈 helpery)
view helpery - __invoke() - is_callable()
33. Jak za鱈t?
PHP 5.3
DI
Tutorial: Getting started with Zend
Framework 2 (beta1) (by Akrabat)
Applications skeleton + module
34. V箪hody
+ m叩te pehled co se dje
+ zmny nejsou tak velk辿
komponenty pib箪vaj鱈 postupn
+ m哲転ete nov vci zkusit pou転鱈vat
je邸t ne転 vyjdou
+ m哲転ete zas叩hnout do v箪voje
35. Nev箪hody
- cokoli, co udl叩te, se m哲転e rozb鱈t
- mus鱈te koukat do zdroj叩ku
- nen鱈 to na produkn鱈 nasazen鱈