Making the most of 2.2

M
MAKING THE MOST OF 2.2
        MARK STORY
         @MARK_STORY
PACKING IN THE GOOD
2.0.0 was release October 18, 2011
Since then 2.1, 2.2, and 2.3 have been released or started.
Over 20 releases since 2.0.0.
Highest release velocity ever for CakePHP.
FOCUS ON PROBLEMS
We've tried to keep releases focused on solving real world problems
                    developers have everyday.
               Make upgrading as easy as possible.
VIEW BLOCKS
                            PROBLEM
Multiple similar views would often contain repeated structural
HTML.
Apps suffered from element-itis to keep HTML DRY.
Piles of elements make code hard to follow and understand.
Inspired by blocks in Jinja/Twig.
Allows you to create slots/blocks in layouts or parent templates.
Helps keep views/layouts more DRY by letting you create
extensible HTML content.
Replaces annoying magic variables like $ c i t _ o _ a o t
                                         srpsfrlyu
and $ o t n _ o _ a o t
      cnetfrlyu.
EXAMPLE
Parent wrapper view with a child view
PARENT VIEW
<1cas"otn-il"<=$hs>ec(tte) ?<h>
 h ls=cnettte>? ti-fth'il'; >/1
<i cas"otn"
 dv ls=cnet>
<=$hs>ec(cnet) ?
 ? ti-fth'otn'; >
<dv
 /i>
<i cas"iea"
 dv ls=sdbr>
<=$hs>ec(sdbr) ?
 ? ti-fth'iea'; >
<dv
 /i>
<ppi (ti-fth'aiain):?
 ?h f $hs>ec(pgnto') >
<i cas"aiain>
 dv ls=pgnto"
<=$hs>ec(pgnto';?
 ? ti-fth'aiain) >
<dv
 /i>
<ppedf ?
 ?h ni; >
CHILD VIEW
<pp$hs>xed'.cmo/iea.t';?
 ?h ti-etn(./omnsdbrcp) >
<pp$hs>sin'il' 'rdc ls';?
 ?h ti-asg(tte, Pout it) >
<pp$hs>tr(cnet) ?
 ?h ti-sat'otn'; >
<>hsi tecnet/>
 pTi s h otn<p
<pp$hs>n(;?
 ?h ti-ed) >

<pp$hs>tr(sdbr) ?
 ?h ti-sat'iea'; >
<>hsi asdbr/>
 pTi s  iea<p
<pp$hs>n(;?
 ?h ti-ed) >
JSON & XML VIEWS
                            PROBLEM
Previously creating JSON and XML views that just serialized data
was a pain.
Tons of repetitive views and layout files required.
Two view classes that allow you to easily serialize data for simple
uses.
Special _ e i l z view variable defines which view variables
         sraie
should be serialized.
You can also use normal view files if you need to massage data first.
Integrates well with existing features like exception handling and
RequestHandlerComponent.
EXAMPLE
<pp
 ?h
/ I acnrle.
 / n  otolr
fnto idx){
 ucin ne(
     $hs>e(tss,$hs>aiae);
      ti-st'ak' ti-pgnt()
     $hs>e(_eilz' ary'ak')
      ti-st'sraie, ra(tss);
}
HASH CLASS
                            PROBLEM
S t full of inconsistencies. Both in the API and path selector
 e is
syntax.
Set::extract() while powerful, is slow and insane inside.
xpath-ish syntax full of un-fixable bugs and not supported in most
methods.
Hash implements >90% of Set's API.
All methods have a consistent signature.
The same dot notation features are supported everywhere.
Up to 1.6x faster on extract().
Most methods are faster as well.
PERFORMANCE COMPARISONS
Do a similar operation 1000 times, on the same data.
Hs:etat$,'n.ril.d)
 ah:xrc(d {}Atcei'   0.215131998
St:xrc(/ril/d,$)
 e:etat'Atcei' d     0.23719382
1.1x improvement
H s : e t a t $ , ' n . o m n . n . d ) 0.173635005
 ah:xrc(d {}Cmet{}i'
St:xrc(/omn/d,$)
 e:etat'Cmeti' d                        0.201920986
1.1x improvement
Hs:mxiesos$)
 ah:aDmnin(d       0.075587987
St:onDm$,tu)
 e:cuti(d re       0.575523138
7.6x improvement
API CONSISTENCY
Every method takes an array of data as the first argument.
Second argument is always one or more paths.
A consistent API is easier to document, understand and remember.
CAKETIME & CAKENUMBER
                      PROBLEM
T m H l e , N m e H l e and T x H l e have some very
 ieepr ubrepr                         etepr
useful methods.
But they are all trapped in a helper.
Expose non HTML related features as a utility library.
Greatly improve timezone handling.
New features for testing & working with datetimes.
EXAMPLE
<pp
 ?h
Ap:ss'aeie,'tlt';
 p:ue(CkTm' Uiiy)
Ap:ss'aeubr,'tlt';
 p:ue(CkNme' Uiiy)

$t =CkTm:tSre(dttm,'mrc/oot';
 uc  aeie:oevr$aeie AeiaTrno)
$oa =CkTm:iTdy$ietm)
 tdy  aeie:soa(tmsap;

$eut=CkNme:tRaalSz(oeeaye;
 rsl  aeubr:oedbeie$nTrbt)
LOGGING++
                         PROBLEM
Granular logging based on application section was impossible.
Log messages were simply broadcast to every connected logger.
Borrowed idea of logging 'scopes' from python's l g i g
                                                   o g n module.
Log messages can be tagged with scopes.
Only loggers interested in those scopes will get scoped messages.
ATTACH A LOGGER WITH A SCOPE
<pp
 ?h
CkLg:ofg'amns,ary
 aeo:cni(pyet' ra(
    'nie = 'mi'
     egn' > Eal
    'cps = ary'amns,'iln',
     soe' > ra(pyet' blig)
    'o = 'akeapecm
     t' > mr@xml.o'
);
 )
LOG MESSAGES WITH A SCOPE
<pp
 ?h
ty{
 r
     $aea-poes$amn)
      gtwy>rcs(pyet;
}cth(amnEcpin$){
  ac  Pyetxeto e
     CkLg:ro(
      aeo:err
          'rnato fie '.$-gtesg(,
           Tascin ald   e>eMsae)
          ary'amns,'iln'
           ra(pyet' blig)
     );
}
NOW TO JOSE
1 of 26

Recommended

Introduction to Twig by
Introduction to TwigIntroduction to Twig
Introduction to Twigmarkstory
7.7K views59 slides
Twig Brief, Tips&Tricks by
Twig Brief, Tips&TricksTwig Brief, Tips&Tricks
Twig Brief, Tips&TricksAndrei Burian
670 views34 slides
Symfony2 and Doctrine2 Integration by
Symfony2 and Doctrine2 IntegrationSymfony2 and Doctrine2 Integration
Symfony2 and Doctrine2 IntegrationJonathan Wage
6.9K views55 slides
Design Patterns in PHP5 by
Design Patterns in PHP5 Design Patterns in PHP5
Design Patterns in PHP5 Wildan Maulana
1.7K views41 slides
Twig tips and tricks by
Twig tips and tricksTwig tips and tricks
Twig tips and tricksJavier Eguiluz
199.3K views185 slides
international PHP2011_Bastian Feder_jQuery's Secrets by
international PHP2011_Bastian Feder_jQuery's Secretsinternational PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretssmueller_sandsmedia
420 views28 slides

More Related Content

What's hot

Php tips-and-tricks4128 by
Php tips-and-tricks4128Php tips-and-tricks4128
Php tips-and-tricks4128PrinceGuru MS
854 views36 slides
Speed up your developments with Symfony2 by
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2Hugo Hamon
4.5K views71 slides
Dependency Injection with PHP 5.3 by
Dependency Injection with PHP 5.3Dependency Injection with PHP 5.3
Dependency Injection with PHP 5.3Fabien Potencier
75K views104 slides
Symfony2 - WebExpo 2010 by
Symfony2 - WebExpo 2010Symfony2 - WebExpo 2010
Symfony2 - WebExpo 2010Fabien Potencier
2.1K views127 slides
Dependency Injection IPC 201 by
Dependency Injection IPC 201Dependency Injection IPC 201
Dependency Injection IPC 201Fabien Potencier
1.6K views103 slides
Php unit the-mostunknownparts by
Php unit the-mostunknownpartsPhp unit the-mostunknownparts
Php unit the-mostunknownpartsBastian Feder
2.6K views26 slides

What's hot(20)

Speed up your developments with Symfony2 by Hugo Hamon
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2
Hugo Hamon4.5K views
Php unit the-mostunknownparts by Bastian Feder
Php unit the-mostunknownpartsPhp unit the-mostunknownparts
Php unit the-mostunknownparts
Bastian Feder2.6K views
Corephpcomponentpresentation 1211425966721657-8 by PrinceGuru MS
Corephpcomponentpresentation 1211425966721657-8Corephpcomponentpresentation 1211425966721657-8
Corephpcomponentpresentation 1211425966721657-8
PrinceGuru MS491 views
Dependency injection - phpday 2010 by Fabien Potencier
Dependency injection - phpday 2010Dependency injection - phpday 2010
Dependency injection - phpday 2010
Fabien Potencier4.3K views
Lithium: The Framework for People Who Hate Frameworks by Nate Abele
Lithium: The Framework for People Who Hate FrameworksLithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate Frameworks
Nate Abele12.2K views
Objects, Testing, and Responsibility by machuga
Objects, Testing, and ResponsibilityObjects, Testing, and Responsibility
Objects, Testing, and Responsibility
machuga17.1K views
Dependency injection in PHP 5.3/5.4 by Fabien Potencier
Dependency injection in PHP 5.3/5.4Dependency injection in PHP 5.3/5.4
Dependency injection in PHP 5.3/5.4
Fabien Potencier37.4K views
PHP 5.3 and Lithium: the most rad php framework by G Woo
PHP 5.3 and Lithium: the most rad php frameworkPHP 5.3 and Lithium: the most rad php framework
PHP 5.3 and Lithium: the most rad php framework
G Woo5.9K views
Your code sucks, let's fix it by Rafael Dohms
Your code sucks, let's fix itYour code sucks, let's fix it
Your code sucks, let's fix it
Rafael Dohms11.1K views
The Zen of Lithium by Nate Abele
The Zen of LithiumThe Zen of Lithium
The Zen of Lithium
Nate Abele2.6K views
The Beauty and the Beast by Bastian Feder
The Beauty and the BeastThe Beauty and the Beast
The Beauty and the Beast
Bastian Feder3.2K views
PHP Traits by mattbuzz
PHP TraitsPHP Traits
PHP Traits
mattbuzz265 views
Can't Miss Features of PHP 5.3 and 5.4 by Jeff Carouth
Can't Miss Features of PHP 5.3 and 5.4Can't Miss Features of PHP 5.3 and 5.4
Can't Miss Features of PHP 5.3 and 5.4
Jeff Carouth3.1K views
Unit and Functional Testing with Symfony2 by Fabien Potencier
Unit and Functional Testing with Symfony2Unit and Functional Testing with Symfony2
Unit and Functional Testing with Symfony2
Fabien Potencier20.4K views
PHP security audits by Damien Seguy
PHP security auditsPHP security audits
PHP security audits
Damien Seguy5.3K views

Similar to Making the most of 2.2

The State of PHPUnit by
The State of PHPUnitThe State of PHPUnit
The State of PHPUnitEdorian
1.6K views72 slides
The State of PHPUnit by
The State of PHPUnitThe State of PHPUnit
The State of PHPUnitEdorian
1.2K views73 slides
The state of PHPUnit by
The state of PHPUnitThe state of PHPUnit
The state of PHPUnitEdorian
2.1K views72 slides
Beginner workshop to angularjs presentation at Google by
Beginner workshop to angularjs presentation at GoogleBeginner workshop to angularjs presentation at Google
Beginner workshop to angularjs presentation at GoogleAri Lerner
3K views97 slides
How Xslate Works by
How Xslate WorksHow Xslate Works
How Xslate WorksGoro Fuji
4.8K views57 slides
I need help with this program and I have the code for this p.pdf by
I need help with this program and I have the code for this p.pdfI need help with this program and I have the code for this p.pdf
I need help with this program and I have the code for this p.pdfadianantsolutions
2 views5 slides

Similar to Making the most of 2.2(20)

The State of PHPUnit by Edorian
The State of PHPUnitThe State of PHPUnit
The State of PHPUnit
Edorian1.6K views
The State of PHPUnit by Edorian
The State of PHPUnitThe State of PHPUnit
The State of PHPUnit
Edorian1.2K views
The state of PHPUnit by Edorian
The state of PHPUnitThe state of PHPUnit
The state of PHPUnit
Edorian2.1K views
Beginner workshop to angularjs presentation at Google by Ari Lerner
Beginner workshop to angularjs presentation at GoogleBeginner workshop to angularjs presentation at Google
Beginner workshop to angularjs presentation at Google
Ari Lerner3K views
How Xslate Works by Goro Fuji
How Xslate WorksHow Xslate Works
How Xslate Works
Goro Fuji4.8K views
I need help with this program and I have the code for this p.pdf by adianantsolutions
I need help with this program and I have the code for this p.pdfI need help with this program and I have the code for this p.pdf
I need help with this program and I have the code for this p.pdf
Introduction to AngularJS by Pat Cito
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
Pat Cito2.7K views
Building modern web apps with html5, javascript, and java by Alexander Gyoshev
Building modern web apps with html5, javascript, and javaBuilding modern web apps with html5, javascript, and java
Building modern web apps with html5, javascript, and java
Alexander Gyoshev10.3K views
Introduction to source{d} Engine and source{d} Lookout by source{d}
Introduction to source{d} Engine and source{d} Lookout Introduction to source{d} Engine and source{d} Lookout
Introduction to source{d} Engine and source{d} Lookout
source{d}141 views
computer notes - Data Structures - 35 by ecomputernotes
computer notes - Data Structures - 35computer notes - Data Structures - 35
computer notes - Data Structures - 35
ecomputernotes11 views
course slides -- powerpoint by webhostingguy
course slides -- powerpointcourse slides -- powerpoint
course slides -- powerpoint
webhostingguy1.8K views
PhpUnit Best Practices by Edorian
PhpUnit Best PracticesPhpUnit Best Practices
PhpUnit Best Practices
Edorian19.6K views
Ch ch-changes cake php2 by markstory
Ch ch-changes cake php2Ch ch-changes cake php2
Ch ch-changes cake php2
markstory2.3K views
Practical catalyst by dwm042
Practical catalystPractical catalyst
Practical catalyst
dwm0425.6K views
Getting started with ES6 by Nitay Neeman
Getting started with ES6Getting started with ES6
Getting started with ES6
Nitay Neeman933 views

More from markstory

Dependency injection in CakePHP by
Dependency injection in CakePHPDependency injection in CakePHP
Dependency injection in CakePHPmarkstory
758 views38 slides
Safer, More Helpful CakePHP by
Safer, More Helpful CakePHPSafer, More Helpful CakePHP
Safer, More Helpful CakePHPmarkstory
1.2K views31 slides
CakePHP - The Road Ahead by
CakePHP - The Road AheadCakePHP - The Road Ahead
CakePHP - The Road Aheadmarkstory
7.6K views64 slides
Future of HTTP in CakePHP by
Future of HTTP in CakePHPFuture of HTTP in CakePHP
Future of HTTP in CakePHPmarkstory
4.3K views55 slides
CakePHP mistakes made 2015 by
CakePHP mistakes made 2015CakePHP mistakes made 2015
CakePHP mistakes made 2015markstory
1.8K views42 slides
New in cakephp3 by
New in cakephp3New in cakephp3
New in cakephp3markstory
2.1K views44 slides

More from markstory(20)

Dependency injection in CakePHP by markstory
Dependency injection in CakePHPDependency injection in CakePHP
Dependency injection in CakePHP
markstory758 views
Safer, More Helpful CakePHP by markstory
Safer, More Helpful CakePHPSafer, More Helpful CakePHP
Safer, More Helpful CakePHP
markstory1.2K views
CakePHP - The Road Ahead by markstory
CakePHP - The Road AheadCakePHP - The Road Ahead
CakePHP - The Road Ahead
markstory7.6K views
Future of HTTP in CakePHP by markstory
Future of HTTP in CakePHPFuture of HTTP in CakePHP
Future of HTTP in CakePHP
markstory4.3K views
CakePHP mistakes made 2015 by markstory
CakePHP mistakes made 2015CakePHP mistakes made 2015
CakePHP mistakes made 2015
markstory1.8K views
New in cakephp3 by markstory
New in cakephp3New in cakephp3
New in cakephp3
markstory2.1K views
PHP WTF by markstory
PHP WTFPHP WTF
PHP WTF
markstory7.1K views
CakePHP 3.0 and beyond by markstory
CakePHP 3.0 and beyondCakePHP 3.0 and beyond
CakePHP 3.0 and beyond
markstory3K views
CakePHP mistakes made confoo 2015 by markstory
CakePHP mistakes made confoo 2015CakePHP mistakes made confoo 2015
CakePHP mistakes made confoo 2015
markstory943 views
CakePHP mistakes made by markstory
CakePHP mistakes madeCakePHP mistakes made
CakePHP mistakes made
markstory2.8K views
Performance and optimization CakeFest 2014 by markstory
Performance and optimization CakeFest 2014Performance and optimization CakeFest 2014
Performance and optimization CakeFest 2014
markstory1.6K views
Road to CakePHP 3.0 by markstory
Road to CakePHP 3.0Road to CakePHP 3.0
Road to CakePHP 3.0
markstory11.1K views
Performance and optimization by markstory
Performance and optimizationPerformance and optimization
Performance and optimization
markstory2.6K views
OWASP Top 10 2013 by markstory
OWASP Top 10 2013OWASP Top 10 2013
OWASP Top 10 2013
markstory7.6K views
CakePHP the yum & yuck by markstory
CakePHP the yum & yuckCakePHP the yum & yuck
CakePHP the yum & yuck
markstory4.6K views
Owasp top 10 by markstory
Owasp top 10Owasp top 10
Owasp top 10
markstory9.2K views
Simple search with elastic search by markstory
Simple search with elastic searchSimple search with elastic search
Simple search with elastic search
markstory6.6K views
Intro to continuous integration by markstory
Intro to continuous integration Intro to continuous integration
Intro to continuous integration
markstory1.1K views
Evented applications with RabbitMQ and CakePHP by markstory
Evented applications with RabbitMQ and CakePHPEvented applications with RabbitMQ and CakePHP
Evented applications with RabbitMQ and CakePHP
markstory6.4K views
PHPunit and you by markstory
PHPunit and youPHPunit and you
PHPunit and you
markstory2.1K views

Recently uploaded

Data-centric AI and the convergence of data and model engineering: opportunit... by
Data-centric AI and the convergence of data and model engineering:opportunit...Data-centric AI and the convergence of data and model engineering:opportunit...
Data-centric AI and the convergence of data and model engineering: opportunit...Paolo Missier
34 views40 slides
Digital Product-Centric Enterprise and Enterprise Architecture - Tan Eng Tsze by
Digital Product-Centric Enterprise and Enterprise Architecture - Tan Eng TszeDigital Product-Centric Enterprise and Enterprise Architecture - Tan Eng Tsze
Digital Product-Centric Enterprise and Enterprise Architecture - Tan Eng TszeNUS-ISS
19 views47 slides
The details of description: Techniques, tips, and tangents on alternative tex... by
The details of description: Techniques, tips, and tangents on alternative tex...The details of description: Techniques, tips, and tangents on alternative tex...
The details of description: Techniques, tips, and tangents on alternative tex...BookNet Canada
121 views24 slides
Understanding GenAI/LLM and What is Google Offering - Felix Goh by
Understanding GenAI/LLM and What is Google Offering - Felix GohUnderstanding GenAI/LLM and What is Google Offering - Felix Goh
Understanding GenAI/LLM and What is Google Offering - Felix GohNUS-ISS
41 views33 slides
[2023] Putting the R! in R&D.pdf by
[2023] Putting the R! in R&D.pdf[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdfEleanor McHugh
38 views127 slides

Recently uploaded(20)

Data-centric AI and the convergence of data and model engineering: opportunit... by Paolo Missier
Data-centric AI and the convergence of data and model engineering:opportunit...Data-centric AI and the convergence of data and model engineering:opportunit...
Data-centric AI and the convergence of data and model engineering: opportunit...
Paolo Missier34 views
Digital Product-Centric Enterprise and Enterprise Architecture - Tan Eng Tsze by NUS-ISS
Digital Product-Centric Enterprise and Enterprise Architecture - Tan Eng TszeDigital Product-Centric Enterprise and Enterprise Architecture - Tan Eng Tsze
Digital Product-Centric Enterprise and Enterprise Architecture - Tan Eng Tsze
NUS-ISS19 views
The details of description: Techniques, tips, and tangents on alternative tex... by BookNet Canada
The details of description: Techniques, tips, and tangents on alternative tex...The details of description: Techniques, tips, and tangents on alternative tex...
The details of description: Techniques, tips, and tangents on alternative tex...
BookNet Canada121 views
Understanding GenAI/LLM and What is Google Offering - Felix Goh by NUS-ISS
Understanding GenAI/LLM and What is Google Offering - Felix GohUnderstanding GenAI/LLM and What is Google Offering - Felix Goh
Understanding GenAI/LLM and What is Google Offering - Felix Goh
NUS-ISS41 views
[2023] Putting the R! in R&D.pdf by Eleanor McHugh
[2023] Putting the R! in R&D.pdf[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdf
Eleanor McHugh38 views
Upskilling the Evolving Workforce with Digital Fluency for Tomorrow's Challen... by NUS-ISS
Upskilling the Evolving Workforce with Digital Fluency for Tomorrow's Challen...Upskilling the Evolving Workforce with Digital Fluency for Tomorrow's Challen...
Upskilling the Evolving Workforce with Digital Fluency for Tomorrow's Challen...
NUS-ISS28 views
The Importance of Cybersecurity for Digital Transformation by NUS-ISS
The Importance of Cybersecurity for Digital TransformationThe Importance of Cybersecurity for Digital Transformation
The Importance of Cybersecurity for Digital Transformation
NUS-ISS27 views
STPI OctaNE CoE Brochure.pdf by madhurjyapb
STPI OctaNE CoE Brochure.pdfSTPI OctaNE CoE Brochure.pdf
STPI OctaNE CoE Brochure.pdf
madhurjyapb12 views
Beyond the Hype: What Generative AI Means for the Future of Work - Damien Cum... by NUS-ISS
Beyond the Hype: What Generative AI Means for the Future of Work - Damien Cum...Beyond the Hype: What Generative AI Means for the Future of Work - Damien Cum...
Beyond the Hype: What Generative AI Means for the Future of Work - Damien Cum...
NUS-ISS34 views
AI: mind, matter, meaning, metaphors, being, becoming, life values by Twain Liu 刘秋艳
AI: mind, matter, meaning, metaphors, being, becoming, life valuesAI: mind, matter, meaning, metaphors, being, becoming, life values
AI: mind, matter, meaning, metaphors, being, becoming, life values
Black and White Modern Science Presentation.pptx by maryamkhalid2916
Black and White Modern Science Presentation.pptxBlack and White Modern Science Presentation.pptx
Black and White Modern Science Presentation.pptx
maryamkhalid291614 views
.conf Go 2023 - Data analysis as a routine by Splunk
.conf Go 2023 - Data analysis as a routine.conf Go 2023 - Data analysis as a routine
.conf Go 2023 - Data analysis as a routine
Splunk93 views
AMAZON PRODUCT RESEARCH.pdf by JerikkLaureta
AMAZON PRODUCT RESEARCH.pdfAMAZON PRODUCT RESEARCH.pdf
AMAZON PRODUCT RESEARCH.pdf
JerikkLaureta15 views
Business Analyst Series 2023 - Week 3 Session 5 by DianaGray10
Business Analyst Series 2023 -  Week 3 Session 5Business Analyst Series 2023 -  Week 3 Session 5
Business Analyst Series 2023 - Week 3 Session 5
DianaGray10209 views
Spesifikasi Lengkap ASUS Vivobook Go 14 by Dot Semarang
Spesifikasi Lengkap ASUS Vivobook Go 14Spesifikasi Lengkap ASUS Vivobook Go 14
Spesifikasi Lengkap ASUS Vivobook Go 14
Dot Semarang35 views

Making the most of 2.2

  • 1. MAKING THE MOST OF 2.2 MARK STORY @MARK_STORY
  • 2. PACKING IN THE GOOD 2.0.0 was release October 18, 2011 Since then 2.1, 2.2, and 2.3 have been released or started. Over 20 releases since 2.0.0. Highest release velocity ever for CakePHP.
  • 3. FOCUS ON PROBLEMS We've tried to keep releases focused on solving real world problems developers have everyday. Make upgrading as easy as possible.
  • 4. VIEW BLOCKS PROBLEM Multiple similar views would often contain repeated structural HTML. Apps suffered from element-itis to keep HTML DRY. Piles of elements make code hard to follow and understand.
  • 5. Inspired by blocks in Jinja/Twig. Allows you to create slots/blocks in layouts or parent templates. Helps keep views/layouts more DRY by letting you create extensible HTML content. Replaces annoying magic variables like $ c i t _ o _ a o t srpsfrlyu and $ o t n _ o _ a o t cnetfrlyu.
  • 6. EXAMPLE Parent wrapper view with a child view
  • 7. PARENT VIEW <1cas"otn-il"<=$hs>ec(tte) ?<h> h ls=cnettte>? ti-fth'il'; >/1 <i cas"otn" dv ls=cnet> <=$hs>ec(cnet) ? ? ti-fth'otn'; > <dv /i> <i cas"iea" dv ls=sdbr> <=$hs>ec(sdbr) ? ? ti-fth'iea'; > <dv /i> <ppi (ti-fth'aiain):? ?h f $hs>ec(pgnto') > <i cas"aiain> dv ls=pgnto" <=$hs>ec(pgnto';? ? ti-fth'aiain) > <dv /i> <ppedf ? ?h ni; >
  • 8. CHILD VIEW <pp$hs>xed'.cmo/iea.t';? ?h ti-etn(./omnsdbrcp) > <pp$hs>sin'il' 'rdc ls';? ?h ti-asg(tte, Pout it) > <pp$hs>tr(cnet) ? ?h ti-sat'otn'; > <>hsi tecnet/> pTi s h otn<p <pp$hs>n(;? ?h ti-ed) > <pp$hs>tr(sdbr) ? ?h ti-sat'iea'; > <>hsi asdbr/> pTi s iea<p <pp$hs>n(;? ?h ti-ed) >
  • 9. JSON & XML VIEWS PROBLEM Previously creating JSON and XML views that just serialized data was a pain. Tons of repetitive views and layout files required.
  • 10. Two view classes that allow you to easily serialize data for simple uses. Special _ e i l z view variable defines which view variables sraie should be serialized. You can also use normal view files if you need to massage data first. Integrates well with existing features like exception handling and RequestHandlerComponent.
  • 11. EXAMPLE <pp ?h / I acnrle. / n otolr fnto idx){ ucin ne( $hs>e(tss,$hs>aiae); ti-st'ak' ti-pgnt() $hs>e(_eilz' ary'ak') ti-st'sraie, ra(tss); }
  • 12. HASH CLASS PROBLEM S t full of inconsistencies. Both in the API and path selector e is syntax. Set::extract() while powerful, is slow and insane inside. xpath-ish syntax full of un-fixable bugs and not supported in most methods.
  • 13. Hash implements >90% of Set's API. All methods have a consistent signature. The same dot notation features are supported everywhere. Up to 1.6x faster on extract(). Most methods are faster as well.
  • 14. PERFORMANCE COMPARISONS Do a similar operation 1000 times, on the same data.
  • 15. Hs:etat$,'n.ril.d) ah:xrc(d {}Atcei' 0.215131998 St:xrc(/ril/d,$) e:etat'Atcei' d 0.23719382 1.1x improvement
  • 16. H s : e t a t $ , ' n . o m n . n . d ) 0.173635005 ah:xrc(d {}Cmet{}i' St:xrc(/omn/d,$) e:etat'Cmeti' d 0.201920986 1.1x improvement
  • 17. Hs:mxiesos$) ah:aDmnin(d 0.075587987 St:onDm$,tu) e:cuti(d re 0.575523138 7.6x improvement
  • 18. API CONSISTENCY Every method takes an array of data as the first argument. Second argument is always one or more paths. A consistent API is easier to document, understand and remember.
  • 19. CAKETIME & CAKENUMBER PROBLEM T m H l e , N m e H l e and T x H l e have some very ieepr ubrepr etepr useful methods. But they are all trapped in a helper.
  • 20. Expose non HTML related features as a utility library. Greatly improve timezone handling. New features for testing & working with datetimes.
  • 21. EXAMPLE <pp ?h Ap:ss'aeie,'tlt'; p:ue(CkTm' Uiiy) Ap:ss'aeubr,'tlt'; p:ue(CkNme' Uiiy) $t =CkTm:tSre(dttm,'mrc/oot'; uc aeie:oevr$aeie AeiaTrno) $oa =CkTm:iTdy$ietm) tdy aeie:soa(tmsap; $eut=CkNme:tRaalSz(oeeaye; rsl aeubr:oedbeie$nTrbt)
  • 22. LOGGING++ PROBLEM Granular logging based on application section was impossible. Log messages were simply broadcast to every connected logger.
  • 23. Borrowed idea of logging 'scopes' from python's l g i g o g n module. Log messages can be tagged with scopes. Only loggers interested in those scopes will get scoped messages.
  • 24. ATTACH A LOGGER WITH A SCOPE <pp ?h CkLg:ofg'amns,ary aeo:cni(pyet' ra( 'nie = 'mi' egn' > Eal 'cps = ary'amns,'iln', soe' > ra(pyet' blig) 'o = 'akeapecm t' > mr@xml.o' ); )
  • 25. LOG MESSAGES WITH A SCOPE <pp ?h ty{ r $aea-poes$amn) gtwy>rcs(pyet; }cth(amnEcpin$){ ac Pyetxeto e CkLg:ro( aeo:err 'rnato fie '.$-gtesg(, Tascin ald e>eMsae) ary'amns,'iln' ra(pyet' blig) ); }