How Symfony Http Object Works
-
Upload
abouzar-kamaee -
Category
Documents
-
view
224 -
download
0
Transcript of How Symfony Http Object Works
-
8/12/2019 How Symfony Http Object Works
1/21
Introduction ToSymfony 2 Internal
Abouzar Kamaee([email protected])
-
8/12/2019 How Symfony Http Object Works
2/21
Overview
Introduction Component Framework Bundle Handling Re ue!t
-
8/12/2019 How Symfony Http Object Works
3/21
Introduction
"#at e$actl% !%m&on% i! 'Ba!ed on o&&icial document! %m&on% i! a H Framework* a#ilo!op#%* and a Communit% + all working toget#er in #armon%.
"#% !%m&on% '%m&on% i! not a &ramework but a pro,ect. -epending on %ourneed!* %ou can c#oo!e to u!e !ome o& t#e %m&on%Component!* t#e ile$ micro+&ramework* or t#e &ull+!tack
&ramework.
-
8/12/2019 How Symfony Http Object Works
4/21
Introduction
"#% !%m&on% '%m&on% i! u!ed b% man% large companie! (like t#e BBC orCB )* b% man% large web!ite! (like /-* wetter.com* 0ocker!)and !ome 1pen+ ource pro,ect! are al!o powered b% %m&on%(C2 e! like -rupal or e3publi!#* librarie! like H 4nit or-octrine* product! like p#pBB or !#opware* and e5en&ramework! like I or 0ara5el).
%m&on% en,o%! a #uge communit% o& u!er! and contributor!6during t#e la!t %ear alone* 7789 people contributed to t#e%m&on% core and t#e communit% created o5er :*;88 bundle! &or
t#e &ull+!tack &ramework. %m&on% al!o #a! !e5eral annualdedicated con&erence! around t#e world and a large number o&u!er group!.
-
8/12/2019 How Symfony Http Object Works
5/21
-
8/12/2019 How Symfony Http Object Works
6/21
-
8/12/2019 How Symfony Http Object Works
7/21
-
8/12/2019 How Symfony Http Object Works
8/21
-
8/12/2019 How Symfony Http Object Works
9/21
Component
/5er%t#ing i! bundle /a!% to u!e t#ird part bundle! /a!% to implement %our!el& bundle!
-
8/12/2019 How Symfony Http Object Works
10/21
-
8/12/2019 How Symfony Http Object Works
11/21
-
8/12/2019 How Symfony Http Object Works
12/21
Framework Bundle
#e Framework Bundle i! t#e bundlet#at tie! t#e main component! andlibrarie! toget#er to make a lig#tweig#t
and &a!t 2?C &ramework. It come! wit#a !en!ible de&ault con&iguration andcon5ention! to ea!e t#e learning cur5e.
-
8/12/2019 How Symfony Http Object Works
13/21
Framework Bundle
Kernel#e HttpKernel cla!! i! t#e central cla!! o& %m&on%< and i!re!pon!ible &or #andling client re ue!t!. It! main goal i! to=con5ert= a Re ue!t ob,ect to a Re!pon!e ob,ect.
/5er% %m&on%< Kernel implement! HttpKernelInter&ace&unction #andle(Re ue!t re ue!t* t%pe* catc# )
-
8/12/2019 How Symfony Http Object Works
14/21
Framework Bundle
Controller!o con5ert a Re ue!t to a Re!pon!e* t#e Kernel relie! on a=Controller=. A Controller can be an% 5alid H callable.
#e Kernel delegate! t#e !election o& w#at Controller !#ould be
e$ecuted to an implementation o& ControllerRe!ol5erInter&acepublic &unction getController(Re ue!t re ue!t)6
public &unction getArgument!(Re ue!t re ue!t* controller)6
-
8/12/2019 How Symfony Http Object Works
15/21
-
8/12/2019 How Symfony Http Object Works
16/21
Handling Reque t
:. Be&ore doing an%t#ing el!e* t#e kernel.re ue!t e5ent i! noti&ied ++i& one o& t#e li!tener! return! a Re!pon!e* it ,ump! to !tep directl%6
-
8/12/2019 How Symfony Http Object Works
17/21
Handling Reque t
;. #e Kernel call! t#e Controller6
E.I& t#e Controller doe! not return a Re!pon!e* li!tener! o& t#ekernel.5iew e5ent can con5ert t#e Controller return 5alue to aRe!pon!e6
.0i!tener! o& t#e kernel.re!pon!e e5ent can manipulate t#eRe!pon!e (content and #eader!)6
. #e Re!pon!e i! returned.
-
8/12/2019 How Symfony Http Object Works
18/21
Handling Reque t
;. #e Kernel call! t#e Controller6
E.I& t#e Controller doe! not return a Re!pon!e* li!tener! o& t#ekernel.5iew e5ent can con5ert t#e Controller return 5alue to aRe!pon!e6
.0i!tener! o& t#e kernel.re!pon!e e5ent can manipulate t#eRe!pon!e (content and #eader!)6
. #e Re!pon!e i! returned.
-
8/12/2019 How Symfony Http Object Works
19/21
-
8/12/2019 How Symfony Http Object Works
20/21
But How !vent "re Fired #
An!wer Ke% i! /5ent -i!patc#er 6)#e %m&on%< /5ent -i!patc#er component implement! t#e2ediator pattern in a !imple and e&&ecti5e wa% to make all t#e!et#ing! po!!ible and to make %our pro,ect! trul% e$ten!ible.
-
8/12/2019 How Symfony Http Object Works
21/21
But How !vent "re Fired #
A li!tener ( H ob,ect) tell! a central di!patc#er ob,ect t#at itwant! to li!ten to t#e kernel.re!pon!e e5ent6
At !ome point* t#e %m&on%< kernel tell! t#e di!patc#er ob,ect todi!patc# t#e kernel.re!pon!e e5ent* pa!!ing wit# it an /5entob,ect t#at #a! acce!! to t#e Re!pon!e ob,ect6
#e di!patc#er noti&ie! (i.e. call! a met#od on) all li!tener! o& t#ekernel.re!pon!e e5ent* allowing eac# o& t#em to makemodi&ication! to t#e Re!pon!e ob,ect.