SlideShare une entreprise Scribd logo
1  sur  30
Télécharger pour lire hors ligne
&

  26 maart 2013
Iwan van Staveren
Agenda
Wie ben ik
Wat is Symfony
Wat is AngularJS
Waarom handig?
Hoe beide te gebruiken
Twig
FosRestBundle
Vragen
Wie ben ik?
     Iwan van Staveren

Software architect bij Oracle
 13 jaar ervaring met PHP
7 jaar ervaring met Symfony

nl.linkedin.com/in/iwanvanstaveren

   Twitter: @istaveren
Wat is                           ?
                  Dat weten we hier wel :-)

                   Volgens symfony.com

     Symfony is a PHP Web Development Framework.
              That doesn’t answer your question?
                    Ok, let’s try that again.
Symfony is a PHP Framework, a Philosophy, and a Community -
               all working together in harmony.
Wat is AngularJS
Een open-source Javascript framework

     Of zo als ze het zelf zeggen:




      HTML enhanced for web apps!
MVC
Models / Views / Controllers
Resources
    vrUe =$eore'aiues' {d 'ojcI')
    a sr   rsuc(/p/sr/, i: @betd};




/ Dfutmtos
 / eal ehd
{
   'e'
   gt:  {ehd'E',
         mto:GT}
   'ae: {ehd'OT}
   sv'   mto:PS',
   'ur' {ehd'E' iArytu}
   qey: mto:GT, sra:re,
   'eoe:{ehd'EEE}
   rmv' mto:DLT',
   'eee:{ehd'EEE}
   dlt' mto:DLT'
};

            ... en nog veel meer!
Resources
..
 .
Ue.rttp.sakr=fnto( {rtr ti.shce;}
 srpooyeiHce  ucin)  eun hsi_akr
Ue.rttp.aktf =fnto(){ti.urn =p }
 srpooyehcSuf  ucinp  hscret  ;
..
 .
HTML
<i n-otolr"tmCnrle"
 dv gcnrle=Iesotolr>
   <>oa ies <nu n-oe=ies tp=nme"/<p
    pTtl tm: ipt gmdl"tm" ye"ubr >/>
   <l
    u>
      <iTtlies{ ies} <l>
       l>oa tm { tm } /i
      <iTtladd{ adw(tm)} <l>
       l>oa de { dToies } /i
   <u>
    /l
<i>
 dv

      Templates in HTML, niet in Javascript!
Controllers
fnto IeCnrle(soe
 ucin tmotolr$cp)
{
  $cp.tm =2
   soeies  ;

    $cp.dTo=fnto(nu){
     soeadw   ucinipt
      rtr ipt+2
      eun nu   ;
    }
}




                Demo
               Items 2


                  Total items 2
                  Items added 4
Hoe te beginnnen
 <tln-p=HceAp>
 hm gap"akrp"
   ..
   .
   <i n-otolr"wsmHceCr"../i>
   dv gcnrle=Aeoeakrtl>.<dv
   <i n-otolr"ueHceCr"../i>
   dv gcnrle=Sprakrtl>.<dv
 <hm>
 /tl




Angular heeft zijn eigen scope in javascript en de DOM
ng-app
vrDmApoue=aglrmdl(DmAp,[mdl')
 a eopMdl    nua.oue'eop' 'oes].
          cni(ucin$nepltPoie){
           ofgfnto(itroaervdr
      $nepltPoie.trSmo(<';
      itroaervdrsatybl'[)
      $nepltPoie.nSmo(>)
      itroaervdredybl'';
   };
   )




              Config & setup
ng-controller
/ DmDt cnrle
 / eoaa otolr
fnto DmDtCr(wno,$otcp,$cp,$tp Ue){
 ucin eoaatl$idw roSoe soe ht, sr

    $cp.sr =Ue.ur(ucindt){
    soeues    srqeyfnto(aa
       / Vldt ec Ue
        / aiae ah sr
    };
    )

    $cp.aiaesr=fnto(){
     soevldtUe    ucinh
       / Dtriei vldue
        / eemn f ai sr
    };
}




           Scoped local methods
Services
aglrmdl(mdl' [nRsuc' 'goke')
nua.oue'oes, 'geore, nCois].
fcoy'akr,fnto(rsuc){
atr(Hce' ucin$eore

  vrHce =$eore"aihce/i" {d "i")
  a akr  rsuc(/p/akr:d, i: @d}

  / Adcasmtos
   / d ls ehd
  Hce.oi =fnto(aa sces err {
   akrlgn   ucindt, ucs, ro)
     $tpps(/p/oi/,dt)
      ht.ot'ailgn' aa.
       scessces.
        ucs(ucs)
       errerr;
        ro(ro)
  };
   )
Directives
Pas de HTML aan zo als jij dat wilt. Mis je een <tab> tag in
         HTML dan kan je hem hiermee maken.
            Eigenlijk een MVC in een tag.
Testen
        Dat zit er bij net als bij Symfony.
       Heet Karma en werkt als unit testen.
Satn Tsaua Sre (tp/vjaiagtu.o/etclr
 trig etclr evr ht:/otjn.ihbcmtsaua)
----------------------------------
 ---------------------------------
if:Tsaua sre satda ht:/oahs:86
 no etclr evr tre t tp/lclot97/
if (anhr:Satn bosrCrm
 no luce) trig rwe hoe
if (hoe2.) Cnetdo sce i TzEbK9x67C
 no Crm 50: once n okt d sbIJagm4L3
Crm 2.:Eeue 1 o 1 SCES(.3 sc /01sc)
 hoe 50 xctd 0 f 0 UCS 045 es  . es
Routing
ng-view
<tln-p=HceAp>
hm gap"akrp"
  ..
  .
  <i n-iw<dv
  dv gve>/i>
<hm>
/tl
The Router
/ Cniuerue
 / ofgr ots
H.ofgfnto(ruervdr $oainrvdr {
 Acni(ucin$otPoie, lctoPoie)
   $otPoie.
   ruervdr
     we(//,{otolr SCr,tmltUl 'sai/hhm'
     hn's' cnrle: Htl epaer: /ttcs.tl
}.
 )
     we(//,{otolr ACr,tmltUl 'sai/hhm'
     hn'a' cnrle: Htl epaer: /ttca.tl
}.
 )
     ohrie{eieto '')
     tews(rdrcT: /};

     / StHM5Md frrue
      / e TL oe o ots
     $oainrvdrhm5oetu)
      lctoPoie.tlMd(re;
};
 )
Gotchas
(Or: things you wish they told you)
$resource
Distributed separately
$cookies
Also distributed separately
Therefore
<citsc"tp:/jxgolai.o/jxlb/nuaj/../nu
 srp r=hts/aa.ogepscmaa/isaglrs105ag
lrj"<srp>
 a.s>/cit
<citsc"tp/cd.nuaj.r/nua-eore105mnj"<
 srp r=ht:/oeaglrsogaglrrsuc-...i.s>
/cit
 srp>
<citsc"tp/cd.nuaj.r/../nua-oke-...i.
 srp r=ht:/oeaglrsog105aglrcois105mn
j"<srp>
 s>/cit
AngularJS is friendly
  But it chooses its friends carefully
Waarom handig?
Meer logica naar de client
Geeft een betere response naar de gebruiker
Minder load op de server
Er komen steeds meer apps
Apps en web pagina's kunnen de zelfde backend API gebruiken
Vraag hoevel % code PHP /
        Javascript
          In 2010?
          In 2013?
          In 2015?
Hoe beide te gebruiken?
           Voeg AngulerJS toe aan je twig template
  { bokfo_cit%
   % lc otsrp }
    { i apdbg%
     % f p.eu }
      <cittp=tx/aacit sc"{ast'ude/eoj/n
       srp ye"etjvsrp" r={ se(bnlsdm/sag
  ua/nua.s)}"<srp>
   lraglrj' }>/cit
      <cittp=tx/aacit sc"{ast'ude/eoj/n
       srp ye"etjvsrp" r={ se(bnlsdm/sag
  ua/nua-eorej' }"<srp>
   lraglrrsuc.s) }>/cit
      <cittp=tx/aacit sc"{ast'ude/eoj/n
       srp ye"etjvsrp" r={ se(bnlsdm/sag
  ua/nua-ij' }"<srp>
   lraglru.s) }>/cit
    { es %
     % le }
      {-jvsrps
       % aacit
        'DmBnl/eore/ulcj/nua/nua.i.s
         @eoudeRsucspbi/saglraglrmnj'
        'DmBnl/eore/ulcj/nua/nua-eoremnj
         @eoudeRsucspbi/saglraglrrsuc.i.
  s'
        'DmBnl/eore/ulcj/nua/nua-imnj'
         @eoudeRsucspbi/saglraglru.i.s
      %}
        <cittp=tx/aacit sc"{astul}"<srp>
         srp ye"etjvsrp" r={ se_r }>/cit
      { edaacit %
       % njvsrps }
    { edf%
     % ni }
  <cittp=tx/aacit sc"{ast'ude/ojruigj
   srp ye"etjvsrp" r={ se(bnlsfssotn/s
Let op! In dev mode gebruik niet de minified versie. Dat debugt
  /otrj' }"<srp>
   rue.s) }>/cit
  <cittp=tx/aacit sc"{pt(fsj_otn_s,{c
   srp ye"etjvsrp" r={ ah'o_sruigj' "a
                 niet echt handig in Javascript
  lbc" "o.otrstaa} }"<srp>
   lak: fsRue.eDt") }>/cit
  { edlc %
   % nbok }
Twig & AngularJS templates
Aangezien zowel AngularJS als Twig {{ }} gebruikt voor variable.
               Moet er één worden aangepast.
        Handigst is AngularJS op de volgende manier:
  vrDmApoue=aglrmdl(DmAp,[mdl')
   a eopMdl    nua.oue'eop' 'oes].
            cni(ucin$nepltPoie){
             ofgfnto(itroaervdr
        $nepltPoie.trSmo(<';
        itroaervdrsatybl'[)
        $nepltPoie.nSmo(>)
        itroaervdredybl'';
     };
     )
FOSRestBundle
Met de hulp van deze bundle krijg je data die normaal naar twig
            gaat eenvoudig terug als json response

     pbi fnto boscin$ae
      ulc ucin okAto(nm)
     {
       $iw=Ve:cet(ra(bos = ary"ok$ae1,"ok
       ve   iw:raeary'ok' > ra(Bo nm " Bo
   $ae2) 'ae = $ae)
    nm ", nm' > nm);

         $iw>eTmlt(AmDmBnl:eohlohm.wg)
         ve-stepae'ceeoudeDm:el.tlti';
         $ade =$hs>e(fsrs.iwhnlr)
         hnlr  ti-gt'o_etve_ade';

         rtr $ade-hnl(ve)
         eun hnlr>ade$iw;
     }

   Geeft voor app_dev.php/demo/books/Iwan?_format=json
  {bos:"okIa 1,Bo Ia 2]"ae:Ia"
   "ok"[Bo wn ""ok wn ",nm""wn}
Vragen


Credits for the slides: Vojta Jína, Miško Hevery, Igor Minar,
                        Patrick Aljord.

Contenu connexe

En vedette

Symfony with angular.pptx
Symfony with angular.pptxSymfony with angular.pptx
Symfony with angular.pptxEsokia
 
Symfony 2 : chapitre 4 - Les services et les formulaires
Symfony 2 : chapitre 4 - Les services et les formulairesSymfony 2 : chapitre 4 - Les services et les formulaires
Symfony 2 : chapitre 4 - Les services et les formulairesAbdelkader Rhouati
 
Desarrollo Web Ágil con Symfony, Bootstrap y Angular
Desarrollo Web Ágil con Symfony, Bootstrap y AngularDesarrollo Web Ágil con Symfony, Bootstrap y Angular
Desarrollo Web Ágil con Symfony, Bootstrap y AngularFreelancer
 
برنامج جمعية بسمة أمل بوجدة لسنة 2013
برنامج جمعية بسمة أمل بوجدة لسنة 2013برنامج جمعية بسمة أمل بوجدة لسنة 2013
برنامج جمعية بسمة أمل بوجدة لسنة 2013Abdelkader Rhouati
 
Symfony2 e Elasticsearch com FosElasticaBundle
Symfony2 e Elasticsearch com FosElasticaBundleSymfony2 e Elasticsearch com FosElasticaBundle
Symfony2 e Elasticsearch com FosElasticaBundleWaldemar Neto
 
Applications secure by default
Applications secure by defaultApplications secure by default
Applications secure by defaultSecuRing
 
PPT on Angular 2 Development Tutorial
PPT on Angular 2 Development TutorialPPT on Angular 2 Development Tutorial
PPT on Angular 2 Development TutorialPaddy Lock
 
Design patterns avec Symfony
Design patterns avec SymfonyDesign patterns avec Symfony
Design patterns avec SymfonyMohammed Rhamnia
 
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...Ryan Weaver
 
AngularJS - Présentation (french)
AngularJS - Présentation (french)AngularJS - Présentation (french)
AngularJS - Présentation (french)Yacine Rezgui
 
deSymfony 2013 - Creando aplicaciones web desde otro ángulo con Symfony y A...
deSymfony 2013 -  Creando aplicaciones web desde otro ángulo con Symfony y A...deSymfony 2013 -  Creando aplicaciones web desde otro ángulo con Symfony y A...
deSymfony 2013 - Creando aplicaciones web desde otro ángulo con Symfony y A...Pablo Godel
 
Introduction to Angular 2
Introduction to Angular 2Introduction to Angular 2
Introduction to Angular 2Knoldus Inc.
 
Getting Started with Angular 2
Getting Started with Angular 2Getting Started with Angular 2
Getting Started with Angular 2FITC
 
RESTful avec symfony 1 et Symfony2
RESTful avec symfony 1 et Symfony2RESTful avec symfony 1 et Symfony2
RESTful avec symfony 1 et Symfony2Xavier Lacot
 
Introduction au business modèle des applications mobile
Introduction au business modèle des applications mobileIntroduction au business modèle des applications mobile
Introduction au business modèle des applications mobileAbdelkader Rhouati
 

En vedette (17)

Symfony with angular.pptx
Symfony with angular.pptxSymfony with angular.pptx
Symfony with angular.pptx
 
Symfony 2 : chapitre 4 - Les services et les formulaires
Symfony 2 : chapitre 4 - Les services et les formulairesSymfony 2 : chapitre 4 - Les services et les formulaires
Symfony 2 : chapitre 4 - Les services et les formulaires
 
Desarrollo Web Ágil con Symfony, Bootstrap y Angular
Desarrollo Web Ágil con Symfony, Bootstrap y AngularDesarrollo Web Ágil con Symfony, Bootstrap y Angular
Desarrollo Web Ágil con Symfony, Bootstrap y Angular
 
برنامج جمعية بسمة أمل بوجدة لسنة 2013
برنامج جمعية بسمة أمل بوجدة لسنة 2013برنامج جمعية بسمة أمل بوجدة لسنة 2013
برنامج جمعية بسمة أمل بوجدة لسنة 2013
 
Symfony2 e Elasticsearch com FosElasticaBundle
Symfony2 e Elasticsearch com FosElasticaBundleSymfony2 e Elasticsearch com FosElasticaBundle
Symfony2 e Elasticsearch com FosElasticaBundle
 
Applications secure by default
Applications secure by defaultApplications secure by default
Applications secure by default
 
PPT on Angular 2 Development Tutorial
PPT on Angular 2 Development TutorialPPT on Angular 2 Development Tutorial
PPT on Angular 2 Development Tutorial
 
Symfony Best Practices
Symfony Best PracticesSymfony Best Practices
Symfony Best Practices
 
Design patterns avec Symfony
Design patterns avec SymfonyDesign patterns avec Symfony
Design patterns avec Symfony
 
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
 
AngularJS - Présentation (french)
AngularJS - Présentation (french)AngularJS - Présentation (french)
AngularJS - Présentation (french)
 
deSymfony 2013 - Creando aplicaciones web desde otro ángulo con Symfony y A...
deSymfony 2013 -  Creando aplicaciones web desde otro ángulo con Symfony y A...deSymfony 2013 -  Creando aplicaciones web desde otro ángulo con Symfony y A...
deSymfony 2013 - Creando aplicaciones web desde otro ángulo con Symfony y A...
 
Introduction to Angular 2
Introduction to Angular 2Introduction to Angular 2
Introduction to Angular 2
 
Getting Started with Angular 2
Getting Started with Angular 2Getting Started with Angular 2
Getting Started with Angular 2
 
RESTful avec symfony 1 et Symfony2
RESTful avec symfony 1 et Symfony2RESTful avec symfony 1 et Symfony2
RESTful avec symfony 1 et Symfony2
 
Introduction au business modèle des applications mobile
Introduction au business modèle des applications mobileIntroduction au business modèle des applications mobile
Introduction au business modèle des applications mobile
 
Réussir sa carrière
Réussir sa carrièreRéussir sa carrière
Réussir sa carrière
 

Similaire à Symfony and Angularjs

Kennismaking Met Puppet
Kennismaking Met PuppetKennismaking Met Puppet
Kennismaking Met Puppetwphaver
 
Software Engineering College 5 -managing data
Software Engineering College 5 -managing dataSoftware Engineering College 5 -managing data
Software Engineering College 5 -managing dataJurjen Helmus
 
HVA - CMD, Ubicomp v1 - Werkcollege week 7 - programmeertips
HVA - CMD, Ubicomp v1 - Werkcollege week 7 - programmeertipsHVA - CMD, Ubicomp v1 - Werkcollege week 7 - programmeertips
HVA - CMD, Ubicomp v1 - Werkcollege week 7 - programmeertipsHarm van Vugt
 
Seminar Copernica Developer
Seminar Copernica DeveloperSeminar Copernica Developer
Seminar Copernica DeveloperCopernica BV
 
Copernica Marketing Software - Presentatie Copernica Developers training
Copernica Marketing Software - Presentatie Copernica Developers trainingCopernica Marketing Software - Presentatie Copernica Developers training
Copernica Marketing Software - Presentatie Copernica Developers trainingCopernica BV
 
Mashups - Snel en eenvoudig data combineren met PHP (deel 1)
Mashups - Snel en eenvoudig data combineren met PHP (deel 1)Mashups - Snel en eenvoudig data combineren met PHP (deel 1)
Mashups - Snel en eenvoudig data combineren met PHP (deel 1)Remco Tolsma
 
Software Engineering College 2 - ETL and databases
Software Engineering College 2 - ETL and databasesSoftware Engineering College 2 - ETL and databases
Software Engineering College 2 - ETL and databasesJurjen Helmus
 
XML tekortkomingen en pluspunten
XML   tekortkomingen en pluspuntenXML   tekortkomingen en pluspunten
XML tekortkomingen en pluspuntenMarc de Graauw
 
Html5 jeugdwerknet
Html5 jeugdwerknetHtml5 jeugdwerknet
Html5 jeugdwerknetHans Rossel
 
Digitale renovaties - Congres 2008 - V-ICT-OR
Digitale renovaties - Congres 2008 - V-ICT-ORDigitale renovaties - Congres 2008 - V-ICT-OR
Digitale renovaties - Congres 2008 - V-ICT-ORBart Gysens
 

Similaire à Symfony and Angularjs (16)

Beginnen met PHP
Beginnen met PHPBeginnen met PHP
Beginnen met PHP
 
Kennismaking Met Puppet
Kennismaking Met PuppetKennismaking Met Puppet
Kennismaking Met Puppet
 
Software Engineering College 5 -managing data
Software Engineering College 5 -managing dataSoftware Engineering College 5 -managing data
Software Engineering College 5 -managing data
 
HVA - CMD, Ubicomp v1 - Werkcollege week 7 - programmeertips
HVA - CMD, Ubicomp v1 - Werkcollege week 7 - programmeertipsHVA - CMD, Ubicomp v1 - Werkcollege week 7 - programmeertips
HVA - CMD, Ubicomp v1 - Werkcollege week 7 - programmeertips
 
Fedora CMA en XSLT
Fedora CMA en XSLTFedora CMA en XSLT
Fedora CMA en XSLT
 
Seminar Copernica Developer
Seminar Copernica DeveloperSeminar Copernica Developer
Seminar Copernica Developer
 
Copernica Marketing Software - Presentatie Copernica Developers training
Copernica Marketing Software - Presentatie Copernica Developers trainingCopernica Marketing Software - Presentatie Copernica Developers training
Copernica Marketing Software - Presentatie Copernica Developers training
 
Mashups - Snel en eenvoudig data combineren met PHP (deel 1)
Mashups - Snel en eenvoudig data combineren met PHP (deel 1)Mashups - Snel en eenvoudig data combineren met PHP (deel 1)
Mashups - Snel en eenvoudig data combineren met PHP (deel 1)
 
Software Engineering College 2 - ETL and databases
Software Engineering College 2 - ETL and databasesSoftware Engineering College 2 - ETL and databases
Software Engineering College 2 - ETL and databases
 
Gegevensbanken 2010 les14
Gegevensbanken 2010 les14Gegevensbanken 2010 les14
Gegevensbanken 2010 les14
 
Hwud04 les3 - Javascript
Hwud04 les3 - JavascriptHwud04 les3 - Javascript
Hwud04 les3 - Javascript
 
NLJUG J-Fall 2011
NLJUG J-Fall 2011NLJUG J-Fall 2011
NLJUG J-Fall 2011
 
Web Security 101
Web Security 101Web Security 101
Web Security 101
 
XML tekortkomingen en pluspunten
XML   tekortkomingen en pluspuntenXML   tekortkomingen en pluspunten
XML tekortkomingen en pluspunten
 
Html5 jeugdwerknet
Html5 jeugdwerknetHtml5 jeugdwerknet
Html5 jeugdwerknet
 
Digitale renovaties - Congres 2008 - V-ICT-OR
Digitale renovaties - Congres 2008 - V-ICT-ORDigitale renovaties - Congres 2008 - V-ICT-OR
Digitale renovaties - Congres 2008 - V-ICT-OR
 

Symfony and Angularjs

  • 1. & 26 maart 2013 Iwan van Staveren
  • 2. Agenda Wie ben ik Wat is Symfony Wat is AngularJS Waarom handig? Hoe beide te gebruiken Twig FosRestBundle Vragen
  • 3. Wie ben ik? Iwan van Staveren Software architect bij Oracle 13 jaar ervaring met PHP 7 jaar ervaring met Symfony nl.linkedin.com/in/iwanvanstaveren Twitter: @istaveren
  • 4. Wat is ? Dat weten we hier wel :-) Volgens symfony.com Symfony is a PHP Web Development Framework. That doesn’t answer your question? Ok, let’s try that again. Symfony is a PHP Framework, a Philosophy, and a Community - all working together in harmony.
  • 5. Wat is AngularJS Een open-source Javascript framework Of zo als ze het zelf zeggen: HTML enhanced for web apps!
  • 6. MVC Models / Views / Controllers
  • 7. Resources vrUe =$eore'aiues' {d 'ojcI') a sr rsuc(/p/sr/, i: @betd}; / Dfutmtos / eal ehd { 'e' gt: {ehd'E', mto:GT} 'ae: {ehd'OT} sv' mto:PS', 'ur' {ehd'E' iArytu} qey: mto:GT, sra:re, 'eoe:{ehd'EEE} rmv' mto:DLT', 'eee:{ehd'EEE} dlt' mto:DLT' }; ... en nog veel meer!
  • 8. Resources .. . Ue.rttp.sakr=fnto( {rtr ti.shce;} srpooyeiHce ucin) eun hsi_akr Ue.rttp.aktf =fnto(){ti.urn =p } srpooyehcSuf ucinp hscret ; .. .
  • 9. HTML <i n-otolr"tmCnrle" dv gcnrle=Iesotolr> <>oa ies <nu n-oe=ies tp=nme"/<p pTtl tm: ipt gmdl"tm" ye"ubr >/> <l u> <iTtlies{ ies} <l> l>oa tm { tm } /i <iTtladd{ adw(tm)} <l> l>oa de { dToies } /i <u> /l <i> dv Templates in HTML, niet in Javascript!
  • 10. Controllers fnto IeCnrle(soe ucin tmotolr$cp) { $cp.tm =2 soeies ; $cp.dTo=fnto(nu){ soeadw ucinipt rtr ipt+2 eun nu ; } } Demo Items 2 Total items 2 Items added 4
  • 11. Hoe te beginnnen <tln-p=HceAp> hm gap"akrp" .. . <i n-otolr"wsmHceCr"../i> dv gcnrle=Aeoeakrtl>.<dv <i n-otolr"ueHceCr"../i> dv gcnrle=Sprakrtl>.<dv <hm> /tl Angular heeft zijn eigen scope in javascript en de DOM
  • 12. ng-app vrDmApoue=aglrmdl(DmAp,[mdl') a eopMdl nua.oue'eop' 'oes]. cni(ucin$nepltPoie){ ofgfnto(itroaervdr $nepltPoie.trSmo(<'; itroaervdrsatybl'[) $nepltPoie.nSmo(>) itroaervdredybl''; }; ) Config & setup
  • 13. ng-controller / DmDt cnrle / eoaa otolr fnto DmDtCr(wno,$otcp,$cp,$tp Ue){ ucin eoaatl$idw roSoe soe ht, sr $cp.sr =Ue.ur(ucindt){ soeues srqeyfnto(aa / Vldt ec Ue / aiae ah sr }; ) $cp.aiaesr=fnto(){ soevldtUe ucinh / Dtriei vldue / eemn f ai sr }; } Scoped local methods
  • 14. Services aglrmdl(mdl' [nRsuc' 'goke') nua.oue'oes, 'geore, nCois]. fcoy'akr,fnto(rsuc){ atr(Hce' ucin$eore vrHce =$eore"aihce/i" {d "i") a akr rsuc(/p/akr:d, i: @d} / Adcasmtos / d ls ehd Hce.oi =fnto(aa sces err { akrlgn ucindt, ucs, ro) $tpps(/p/oi/,dt) ht.ot'ailgn' aa. scessces. ucs(ucs) errerr; ro(ro) }; )
  • 15. Directives Pas de HTML aan zo als jij dat wilt. Mis je een <tab> tag in HTML dan kan je hem hiermee maken. Eigenlijk een MVC in een tag.
  • 16. Testen Dat zit er bij net als bij Symfony. Heet Karma en werkt als unit testen. Satn Tsaua Sre (tp/vjaiagtu.o/etclr trig etclr evr ht:/otjn.ihbcmtsaua) ---------------------------------- --------------------------------- if:Tsaua sre satda ht:/oahs:86 no etclr evr tre t tp/lclot97/ if (anhr:Satn bosrCrm no luce) trig rwe hoe if (hoe2.) Cnetdo sce i TzEbK9x67C no Crm 50: once n okt d sbIJagm4L3 Crm 2.:Eeue 1 o 1 SCES(.3 sc /01sc) hoe 50 xctd 0 f 0 UCS 045 es . es
  • 18. ng-view <tln-p=HceAp> hm gap"akrp" .. . <i n-iw<dv dv gve>/i> <hm> /tl
  • 19. The Router / Cniuerue / ofgr ots H.ofgfnto(ruervdr $oainrvdr { Acni(ucin$otPoie, lctoPoie) $otPoie. ruervdr we(//,{otolr SCr,tmltUl 'sai/hhm' hn's' cnrle: Htl epaer: /ttcs.tl }. ) we(//,{otolr ACr,tmltUl 'sai/hhm' hn'a' cnrle: Htl epaer: /ttca.tl }. ) ohrie{eieto '') tews(rdrcT: /}; / StHM5Md frrue / e TL oe o ots $oainrvdrhm5oetu) lctoPoie.tlMd(re; }; )
  • 20. Gotchas (Or: things you wish they told you)
  • 23. Therefore <citsc"tp:/jxgolai.o/jxlb/nuaj/../nu srp r=hts/aa.ogepscmaa/isaglrs105ag lrj"<srp> a.s>/cit <citsc"tp/cd.nuaj.r/nua-eore105mnj"< srp r=ht:/oeaglrsogaglrrsuc-...i.s> /cit srp> <citsc"tp/cd.nuaj.r/../nua-oke-...i. srp r=ht:/oeaglrsog105aglrcois105mn j"<srp> s>/cit
  • 24. AngularJS is friendly But it chooses its friends carefully
  • 25. Waarom handig? Meer logica naar de client Geeft een betere response naar de gebruiker Minder load op de server Er komen steeds meer apps Apps en web pagina's kunnen de zelfde backend API gebruiken
  • 26. Vraag hoevel % code PHP / Javascript In 2010? In 2013? In 2015?
  • 27. Hoe beide te gebruiken? Voeg AngulerJS toe aan je twig template { bokfo_cit% % lc otsrp } { i apdbg% % f p.eu } <cittp=tx/aacit sc"{ast'ude/eoj/n srp ye"etjvsrp" r={ se(bnlsdm/sag ua/nua.s)}"<srp> lraglrj' }>/cit <cittp=tx/aacit sc"{ast'ude/eoj/n srp ye"etjvsrp" r={ se(bnlsdm/sag ua/nua-eorej' }"<srp> lraglrrsuc.s) }>/cit <cittp=tx/aacit sc"{ast'ude/eoj/n srp ye"etjvsrp" r={ se(bnlsdm/sag ua/nua-ij' }"<srp> lraglru.s) }>/cit { es % % le } {-jvsrps % aacit 'DmBnl/eore/ulcj/nua/nua.i.s @eoudeRsucspbi/saglraglrmnj' 'DmBnl/eore/ulcj/nua/nua-eoremnj @eoudeRsucspbi/saglraglrrsuc.i. s' 'DmBnl/eore/ulcj/nua/nua-imnj' @eoudeRsucspbi/saglraglru.i.s %} <cittp=tx/aacit sc"{astul}"<srp> srp ye"etjvsrp" r={ se_r }>/cit { edaacit % % njvsrps } { edf% % ni } <cittp=tx/aacit sc"{ast'ude/ojruigj srp ye"etjvsrp" r={ se(bnlsfssotn/s Let op! In dev mode gebruik niet de minified versie. Dat debugt /otrj' }"<srp> rue.s) }>/cit <cittp=tx/aacit sc"{pt(fsj_otn_s,{c srp ye"etjvsrp" r={ ah'o_sruigj' "a niet echt handig in Javascript lbc" "o.otrstaa} }"<srp> lak: fsRue.eDt") }>/cit { edlc % % nbok }
  • 28. Twig & AngularJS templates Aangezien zowel AngularJS als Twig {{ }} gebruikt voor variable. Moet er één worden aangepast. Handigst is AngularJS op de volgende manier: vrDmApoue=aglrmdl(DmAp,[mdl') a eopMdl nua.oue'eop' 'oes]. cni(ucin$nepltPoie){ ofgfnto(itroaervdr $nepltPoie.trSmo(<'; itroaervdrsatybl'[) $nepltPoie.nSmo(>) itroaervdredybl''; }; )
  • 29. FOSRestBundle Met de hulp van deze bundle krijg je data die normaal naar twig gaat eenvoudig terug als json response pbi fnto boscin$ae ulc ucin okAto(nm) { $iw=Ve:cet(ra(bos = ary"ok$ae1,"ok ve iw:raeary'ok' > ra(Bo nm " Bo $ae2) 'ae = $ae) nm ", nm' > nm); $iw>eTmlt(AmDmBnl:eohlohm.wg) ve-stepae'ceeoudeDm:el.tlti'; $ade =$hs>e(fsrs.iwhnlr) hnlr ti-gt'o_etve_ade'; rtr $ade-hnl(ve) eun hnlr>ade$iw; } Geeft voor app_dev.php/demo/books/Iwan?_format=json {bos:"okIa 1,Bo Ia 2]"ae:Ia" "ok"[Bo wn ""ok wn ",nm""wn}
  • 30. Vragen Credits for the slides: Vojta Jína, Miško Hevery, Igor Minar, Patrick Aljord.