WHO'S TALKING?
Gediminas Morkevičius aka @l3pp4rd

I code with - PHP, Go, JavaScript, C
I'm an open-source geek - ViM, Arc...
SYMFONYCON WARSAW 2013

INCREASE PRODUCTIVITY WITH
DOCTRINE2 BEHAVIORAL EXTENSIONS
SOME HISTORY
The initial commit 2010-09-03 MIT licensed
Maintained ever since
Purpose - provide common model behaviors
Der...
AN EXAMPLE
<pp
?h
nmsaeEtt;
aepc niy
ueGdoMpigAntto a Gdo
s emapnnoain s em;
ueDcrnRapn a OM
s otieOMMpig s R;
/*
*
*@Rniy...
HOW EXTENSIONS WORK?
SLUGGABLE
Transforms fields into an url friendly slug. Ensures
uniqueness if required.
/*
*
*@emlgfed="oe,"il",sprtr"" sye...
TRANSLATABLE
/*
*
*@emrnltbe
GdoTasaal
*@Rounlnt=4
OMClm(egh6)
*
/
piae$il;
rvt tte
/*
*
*@emrnltbe
GdoTasaal
*@Rountp=tx"...
By default, puts all translations into a single translation
table. It is not performance wise. Uses locale from listener.
TRANSLATION QUERY HINTS
$ur =$m>raeur(SLC pFO Ettrdc pODRB ptte)
qey
e-cetQey"EET
RM niyPout
RE Y .il";
$ur-stit
qey>eHn(
...
TIMESTAMPABLE
Sets timestamps for you. Derived extensions: IpTraceable,
Blameable
/*
*
*@emietmal(n"rae)
GdoTmsapbeo=cet"
...
SORTABLE
Tracks sorting position on your entity
/*
*
*@emotbeoiin
GdoSralPsto
*@Rountp=itgr)
OMClm(ye"nee"
*
/
piae$oiin
r...
SOFTDELETEABLE
Softly removes your entities, so they get filtered out
afterwards, but maintain in the database.
/*
*
*@emo...
Given the actions are performed:
$0=nwEttrdc;
p
e niyPout
$0>eTte'ilb sfdltd)
p-stil(Wl e oteee';
$1=nwEttrdc;
p
e niyPout...
NESTED-SET TREE
Manages your entity as Nested-Set strategy based tree.
<pp
?h
nmsaeEtt;
aepc niy
ueGdoMpigAntto a Gdo
s em...
How the tree looks in database:
How to keep your tree records secure from getting
compromised during concurrent requests?
Given we have entities:
/*
*
*@R...
On every request when you move, insert Project you have a
hard relation Organisation. Meaning, you have to select the
spec...
Read more about available locking mechanisms supported
by database you are using, some references:
Transactions and concur...
FUTURE PLANS:
1.
2.
3.
4.
5.
6.

One next big version upgrade expected 2014
Simplify integration without any preconfigurat...
THANK YOU

Powered by: Revealjs
Upcoming SlideShare
Loading in …5
×

Increase productivity with doctrine2 extensions

1,328 views
1,139 views

Published on

The general talk was about using extensions for symfony2 and doctrine2 to increase productivity and simplify daily tasks. These slides mainly introduce the best features of extensions.

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,328
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
6
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Increase productivity with doctrine2 extensions

  1. 1. WHO'S TALKING? Gediminas Morkevičius aka @l3pp4rd I code with - PHP, Go, JavaScript, C I'm an open-source geek - ViM, Arch Linux, DWM user And I share my stuff github.com/l3pp4rd
  2. 2. SYMFONYCON WARSAW 2013 INCREASE PRODUCTIVITY WITH DOCTRINE2 BEHAVIORAL EXTENSIONS
  3. 3. SOME HISTORY The initial commit 2010-09-03 MIT licensed Maintained ever since Purpose - provide common model behaviors Derive metadata mapping and caching technics Be a framework independent library
  4. 4. AN EXAMPLE <pp ?h nmsaeEtt; aepc niy ueGdoMpigAntto a Gdo s emapnnoain s em; ueDcrnRapn a OM s otieOMMpig s R; /* * *@Rniy OMEtt *@emoteeebefedae"eeeA" GdoSfDltal(ilNm=dltdt) * / casPout ls rdc { /* * *@emrnltbe GdoTasaal *@Rounlnt=4 OMClm(egh6) * / piae$il; rvt tte /* * *@emlgfed="il",udtbefle GdoSu(ils{tte} paal=as) *@Rounlnt=4 uiu=re OMClm(egh6, nqetu) * / piae$lg rvt su; /* * *@emietmal(n"rae) GdoTmsapbeo=cet" *@Rountp=dttm" OMClm(ye"aeie) * / piae$raeA; rvt cetdt /* *
  5. 5. HOW EXTENSIONS WORK?
  6. 6. SLUGGABLE Transforms fields into an url friendly slug. Ensures uniqueness if required. /* * *@emlgfed="oe,"il",sprtr"" sye"ae" GdoSu(ils{cd" tte} eaao=-, tl=cml) *@Rounlnt=4 uiu=re OMClm(egh6, nqetu) * / piae$lg rvt su; Default transliterator transforms utf-8 characters to their ASCII equivalent
  7. 7. TRANSLATABLE /* * *@emrnltbe GdoTasaal *@Rounlnt=4 OMClm(egh6) * / piae$il; rvt tte /* * *@emrnltbe GdoTasaal *@Rountp=tx" nlal=re OMClm(ye"et, ulbetu) * / piae$ecito; rvt dsrpin Can link to a specific entity for translations. That would allow to use a direct foreign key constraint and optimize for better performance
  8. 8. By default, puts all translations into a single translation table. It is not performance wise. Uses locale from listener.
  9. 9. TRANSLATION QUERY HINTS $ur =$m>raeur(SLC pFO Ettrdc pODRB ptte) qey e-cetQey"EET RM niyPout RE Y .il"; $ur-stit qey>eHn( DcrnRur:HN_UTMOTU_AKR otieOMQey:ITCSO_UPTWLE, 'emrnltbeQeyTeWlernltoWle' GdoTasaalurreakrTasainakr ) ; $ur-stitTasaalLsee:HN_RNLTBELCL,'e) qey>eHn(rnltbeitnr:ITTASAAL_OAE d'; $erdcs=$ur-gteut) dPout qey>eRsl(; arywl(dPout,fnto(niyPout$){ ra_ak$erdcs ucinEttrdc p eh "o <$-gtil(} wt dsrpin<$-gtecito(}" co Gt {p>eTte)> ih ecito {p>eDsrpin)>n; }; ) / Gt<pe>wt dsrpin<rct> / o Äfl ih ecito Fühe / Gt<rue>wt dsrpin<rct> / o Tabn ih ecito Fühe
  10. 10. TIMESTAMPABLE Sets timestamps for you. Derived extensions: IpTraceable, Blameable /* * *@emietmal(n"rae) GdoTmsapbeo=cet" *@Rountp=dttm" OMClm(ye"aeie) * / piae$raeA; rvt cetdt /* * *@emietmal(n"pae) GdoTmsapbeo=udt" *@Rountp=dttm" OMClm(ye"aeie) * / piae$paeA; rvt udtdt /* * *@emietmal(n"hne,fed"ttscd" vle1 GdoTmsapbeo=cag" il=sau.oe, au=) *@Rountp=dttm" nlal=re OMClm(ye"aeie, ulbetu) * / piae$ulseA; rvt pbihdt
  11. 11. SORTABLE Tracks sorting position on your entity /* * *@emotbeoiin GdoSralPsto *@Rountp=itgr) OMClm(ye"nee" * / piae$oiin rvt psto; /* * *@emotberu GdoSralGop *@Rayon(agtniy"aeoy) OMMnTOetreEtt=Ctgr" * / piae$aeoy rvt ctgr;
  12. 12. SOFTDELETEABLE Softly removes your entities, so they get filtered out afterwards, but maintain in the database. /* * *@emoteeebefedae"eeeA" GdoSfDltal(ilNm=dltdt) *@Rniy OMEtt * / casPout ls rdc { /* * *@Rounlnt=4 OMClm(egh6) * / piae$il; rvt tte /* * *@Rountp=dttm" nlal=re OMClm(ye"aeie, ulbetu) * / piae$eeeA; rvt dltdt } /.. /.
  13. 13. Given the actions are performed: $0=nwEttrdc; p e niyPout $0>eTte'ilb sfdltd) p-stil(Wl e oteee'; $1=nwEttrdc; p e niyPout $1>eTte'rlyscesu pout) p-stil(Tul ucsfl rdc'; $m>ess(p) e-prit$0; $m>ess(p) e-prit$1; $m>ls(; e-fuh) / a sm pit pouti rmvd / t oe on, rdc s eoe $m>eoe$0; e-rmv(p) $m>ls(; e-fuh) eh cut$m>eRpstr(Ettrdc'-fnAl); co on(e-gteoioy'niyPout)>idl() / rsl i:1 / eut s
  14. 14. NESTED-SET TREE Manages your entity as Nested-Set strategy based tree. <pp ?h nmsaeEtt; aepc niy ueGdoMpigAntto a Gdo s emapnnoain s em; ueDcrnRapn a OM s otieOMMpig s R; /* * *@emretp=nse" GdoTe(ye"etd) *@RniyrpstrCas"emreEtteoioyNseTeRpstr" OMEtt(eoioyls=GdoTeniyRpstretdreeoioy) * / casCtgr ls aeoy { /* * *@Rountp=itgr) OMClm(ye"nee" *@Rd OMI *@ReeaeVle OMGnrtdau * / piae$d rvt i; /* * *@Rounlnt=4 OMClm(egh6) * / piae$il; rvt tte /* * *@emreet GdoTeLf *@Rountp=itgr) OMClm(ye"nee" * /
  15. 15. How the tree looks in database:
  16. 16. How to keep your tree records secure from getting compromised during concurrent requests? Given we have entities: /* * *@Rniy OMEtt * / casOgnsto {*.*} ls raiain /../ /* * *@emretp=nse" GdoTe(ye"etd) *@RniyrpstrCas"emreEtteoioyNseTeRpstr" OMEtt(eoioyls=GdoTeniyRpstretdreeoioy) * / casPoet ls rjc { /* * *@Rayon(agtniy"raiain) OMMnTOetreEtt=Ognsto" *@RonounrfrneClmNm=i" nlal=as) OMJiClm(eeecdounae"d, ulbefle * / piae$raiain rvt ognsto; } /../ *.*
  17. 17. On every request when you move, insert Project you have a hard relation Organisation. Meaning, you have to select the specific organisation in order to update the tree. ueDcrnBLLcMd; s otieDAokoe $on=$m>eCneto(; cn e-gtoncin) / sattascin / tr rnato $on>eiTascin) cn-bgnrnato(; ty{ r / slcsognsto frudt -lcsi fray / eet raiain o pae ok t o n / ra/rt atmt utlti tascined / edwie teps ni hs rnato ns $r =$m>id"niyOgnsto" $rI,LcMd:PSIITCWIE; og e-fn(Ettraiain, ogd okoe:ESMSI_RT) / cet anwctgr / rae e aeoy $uPoet=nwPoet sbrjc e rjc; $uPoet>eTte$PS[tte]; sbrjc-stil(_OT"il") $uPoet>eOgnsto(og; sbrjc-straiain$r) $aetrjc =$m>id"niyPoet,$PS[prn_d]; prnPoet e-fn(Ettrjc" _OT"aeti") / pritadfuh / ess n ls $m>eRpstr(Ettrjc" e-gteoioy"niyPoet) -pritsisCidf$uPoet $aetrjc) >essAFrthlO(sbrjc, prnPoet; $m>ls(; e-fuh) $on>omt) cn-cmi(; }cth(Ecpin$){ ac xeto e $on>olak) cn-rlbc(; trw$; ho e }
  18. 18. Read more about available locking mechanisms supported by database you are using, some references: Transactions and concurrency on Doctrine2 website Locking reads on MySQL 5.5 manual page Any actions which does atomic operations needs to be secured including Sortable extension.
  19. 19. FUTURE PLANS: 1. 2. 3. 4. 5. 6. One next big version upgrade expected 2014 Simplify integration without any preconfiguration using sensible defaults. Improve extensions based on the issues learned. Make them less feature rich, but more customizable. Improve documentation, add helper commands to review active listeners and watched entities. Maintain compatibility without changes to public interface. Progress can be followed on pull request
  20. 20. THANK YOU Powered by: Revealjs

×