PHP 5.4 - Begin your love affair with traits
Upcoming SlideShare
Loading in...5
×
 

PHP 5.4 - Begin your love affair with traits

on

  • 15,801 views

Slides for my talk at OSDC PHP MiniConf. November 14, 2011.

Slides for my talk at OSDC PHP MiniConf. November 14, 2011.

Statistics

Views

Total Views
15,801
Views on SlideShare
9,492
Embed Views
6,309

Actions

Likes
24
Downloads
247
Comments
5

27 Embeds 6,309

http://blog.candycane.jp 4422
http://d.hatena.ne.jp 919
http://grahamweldon.com 593
http://www.developersnacks.com 79
http://tipshare.info 77
http://jalalbd.wordpress.com 74
https://twitter.com 26
http://webcache.googleusercontent.com 16
http://shoyan.hatenablog.com 15
http://www.techgig.com 15
http://grahamweldon.dev 10
http://2011.osdc.com.au 10
http://a0.twimg.com 9
http://paper.li 8
http://php-ninja.com 7
http://osdc.com.au 7
http://coderwall.com 6
http://translate.googleusercontent.com 5
http://tubemote.com 2
http://115.112.206.131 2
https://umasseval.blackboard.com 1
http://www.google.com 1
http://tomc3d.com 1
http://cktrunk.pantera.epistema.local 1
http://213.8.145.172 1
http://cache.yahoofs.jp 1
http://www.tomc3d.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

PHP 5.4 - Begin your love affair with traits PHP 5.4 - Begin your love affair with traits Presentation Transcript

  • PHP 5.4Begin your love affair with Traits- Graham Weldon
  • Graham WeldonPHP developer since... foreverCakePHP contributor/ evangelistSerial conference speakerGaming enthusiastBeer drinkerhttp://grahamweldon.comhttp://cakedc.comhttp://cakephp.orgTwitter: @predominant
  • SydPHPWe’ve got awesome stuff coming upVisit us! http://sydphp.orgNovember MeetupDecember “Phunconference 2”January Australia Day BBQ
  • What PHP Version? PHP 4 PHP 5.1 PHP 5.2 PHP 5.3 PHP 5.4 PHP 6 (Yes, there are some people using it)
  • 100 75 50 25PHP 3 PHP 4 0 PHP 5 PHP 6 Data courtesy of w3techs.com
  • 80 60 40 205.0 5.1 5.2 0 5.3 5.4 Data courtesy of w3techs.com
  • Traditionally slow adopters PHP 4 to PHP 5 was a painfully slow upgrade for the global community Shared hosts retained old versions Object handling was different PHP 5.1 on CentOS People don’t upgrade stable systems PHP 5.2 massive exposure Again, people don’t upgrade stable systems PHP 5.3 used, but not fully
  • Why slow adopters? Shared hosts Established applications Upgrade path Old excuses
  • Why adopt early? New language features More elegant ways to solve problems Cleaner code Adopting early gets you noticed
  • What about instability? Be sensible with production-ready systems Don’t use the bleeding edge Confirm functionality Unit Testing Integration testing Load testing If your tests pass, then phase in the new system Use sensible reporting / monitoring
  • Enter PHP 5.4 (RC1)
  • PHP 5.4-RC1 RC1 was released for QA on 11th November 2011 Some new features, plenty of bug fixes You can download it for yourself! http://qa.php.net/ Give it a try See if your applications run on it
  • PHP 5.4New Language Features and Improvements
  • Upload Progress
  • Binary Notation!
  • Array short syntaxhttps://wiki.php.net/rfc/shortsyntaxforarrays
  • Array dereferencinghttps://wiki.php.net/rfc/functionarraydereferencing
  • Class member access on instantiation
  • Closures (Current)
  • Closures (Array)https://wiki.php.net/rfc/indirect-method-call-by-array-var
  • But this doesn’t work... :-(
  • Closures and ‘$this’https://wiki.php.net/rfc/closures/object-extension
  • Callable Typehinthttps://wiki.php.net/rfc/callable
  • JsonSerializable Interface
  • Short Tag echo - Always available
  • Oh, and there is a built-inweb server now. Yay?
  • https://wiki.php.net/
  • PHP Traits
  • Whats the big deal? Elegant code re-use Without complicated multiple inheritance No diamond issues Kinda like interfaces But provides implementation Other languages are doing similar things PHP is keeping up with the trends
  • A look atGolang interfaces
  • PHP’s approach Traits define small sections of reusable code This code can be included in any class There is a loading precedence order Puts developers in control Looks a feels natural No need to write things twice Override capabilities
  • PHP TraitsExample
  • PHP TraitsExample
  • PHP TraitsReal Example
  • SometimesTraits needAdjustmentMaybe log() needs tobe public in youruse case.
  • ChangeMethodsas you likelog() is now accessibleto the User instancein this context.
  • CustomiseFurtherChange method namesif you’re into thatsort of thing.Provide preferences.
  • Graham Weldon Twitter: @predominant http://grahamweldon.com Its over! http://cakedc.comQuestions? http://cakephp.org Get in touch if you want to know more about this presentation, PHP in general, or anything. :-)