$30 off During Our Annual Pro Sale. View Details »

Good ol' PHP

Good ol' PHP

Presentation by Rui Lima.

PHP ain't dead and it's like good wine, getting better every year. In this talk we'll go through what's new in PHP7, and how its new engine stands next to HHVM, while highlighting new syntax goodies.

Porto Codes

May 18, 2016
Tweet

More Decks by Porto Codes

Other Decks in Technology

Transcript

  1. Good ol’PHP
    @rapzo - may 18th - 2016
    A tale on how to turn hate into love

    View Slide

  2. Rui Lima
    front-end developer @blippt
    Jack of all trades @exoticosembraga
    @rapzo
    github.com/rapzo
    @rapzo - may 18th - 2016

    View Slide

  3. PHP SUCKS!!1

    View Slide

  4. PHP stands for…
    Personal Home Page………
    We came a loooong way
    Now it’s PHP: Hypertext Preprocessor...
    @rapzo - may 18th - 2016

    View Slide

  5. Back in the later 1990s and early 2000
    php was the lingua franca for web
    development
    But it was bugged as hell
    @rapzo - may 18th - 2016

    View Slide

  6. php 5.3 came out and php-fig was
    created!!
    @rapzo - may 18th - 2016
    2009

    View Slide

  7. psr-1 coding standards (who gives a damn)
    psr-2 code style (srsly?!?!)
    psr-3 LoggerInterface
    psr-4 ex-psr-0, the autoloading standard
    psr-6 CacheInterface (alright…)
    psr-7 http message interface (aleluia!!)
    @rapzo - may 18th - 2016
    php-fig

    View Slide

  8. First community adopted package manager
    for PHP.
    Like many others, relies on github to
    solve its dependencies
    @rapzo - may 18th - 2016
    composer

    View Slide

  9. @rapzo - may 18th - 2016

    View Slide

  10. @rapzo - may 18th - 2016
    composer
    packagist is your friend!

    View Slide

  11. Yeah, this is like, what
    every other language
    already has...

    View Slide

  12. @rapzo - may 18th - 2016
    language features
    from php 5.3 onwards… the others are rubbish anyways...
    5.3 the biggest leap
    5.4 array shorthands, traits and a webserver!
    5.5 generators (i yield!) and expressions in
    primitives
    5.6 constant expressions, …$params notation
    5.7 when everybody went bananas!
    long wait....
    7.0 major shift

    View Slide

  13. @rapzo - may 18th - 2016
    php 5.3
    namespaces for logically code separation
    late static binding for static inheritance
    closures don’t we just love to provide
    functions as arguments!
    nowdoc & heredoc output buffered content
    constants immutable data FTW!
    shorthand ternary ?: ‘hello’;
    dynamic access to static $a::$b \m/

    View Slide

  14. @rapzo - may 18th - 2016
    php 5.3
    namespaces for logically code separation

    View Slide

  15. @rapzo - may 18th - 2016
    php 5.3
    late static binding for static inheritance

    View Slide

  16. @rapzo - may 18th - 2016
    php 5.3
    closures don’t we just love to provide functions
    as arguments!

    View Slide

  17. @rapzo - may 18th - 2016
    php 5.3
    nowdoc & heredoc output buffered content

    View Slide

  18. @rapzo - may 18th - 2016
    php 5.3
    constants immutable data FTW!

    View Slide

  19. @rapzo - may 18th - 2016
    php 5.3
    shorthand ternary ?: ‘hello’;

    View Slide

  20. @rapzo - may 18th - 2016
    php 5.3
    dynamic access to static $a::$b \m/

    View Slide

  21. @rapzo - may 18th - 2016
    php 5.4
    traits for class decoration
    array short syntax no more array(‘a’ => ‘b’)
    function array deref hello()[0]
    closures can have a scope
    short open tags for echoing always available
    instantiating access (new ABC)->a()->b()->c()
    Class::{expressions} awesome!
    binary is now available
    session track for upload hooray progress bars
    webserver aleluia!

    View Slide

  22. @rapzo - may 18th - 2016
    php 5.4
    traits for class decoration

    View Slide

  23. @rapzo - may 18th - 2016
    php 5.4
    array short syntax no more array(‘a’ => ‘b’)

    View Slide

  24. @rapzo - may 18th - 2016
    php 5.4
    function array deref hello()[0]

    View Slide

  25. @rapzo - may 18th - 2016
    php 5.4
    closures can have a scope

    View Slide

  26. @rapzo - may 18th - 2016
    php 5.4
    short open tags for echoing always available

    View Slide

  27. @rapzo - may 18th - 2016
    php 5.4
    instantiating access (new ABC)->a()->b()->c()

    View Slide

  28. @rapzo - may 18th - 2016
    php 5.4
    Class::{expressions} awesome!

    View Slide

  29. @rapzo - may 18th - 2016
    php 5.4
    binary is now available

    View Slide

  30. @rapzo - may 18th - 2016
    php 5.4
    session track for upload hooray progress bars

    View Slide

  31. @rapzo - may 18th - 2016
    php 5.4
    webserver aleluia!

    View Slide

  32. @rapzo - may 18th - 2016
    php 5.5
    generators multiple results from the same
    function
    finally who haven’t discard an exception
    before
    primitives accept functions such as foreach
    empty() accepts expressions, like functions
    dereferencing for arrays and strings
    ::class for dynamic class name access
    OPcache for precompiled code storage

    View Slide

  33. @rapzo - may 18th - 2016
    php 5.5
    generators multiple results from the same
    function

    View Slide

  34. @rapzo - may 18th - 2016
    php 5.5
    finally who haven’t discard an exception
    before

    View Slide

  35. @rapzo - may 18th - 2016
    php 5.5
    primitives accept functions such as foreach

    View Slide

  36. @rapzo - may 18th - 2016
    php 5.5
    empty() accepts expressions, like functions

    View Slide

  37. @rapzo - may 18th - 2016
    php 5.5
    dereferencing for arrays and strings

    View Slide

  38. @rapzo - may 18th - 2016
    php 5.5
    ::class for dynamic class name access

    View Slide

  39. @rapzo - may 18th - 2016
    php 5.5
    OPcache for precompiled code storage

    View Slide

  40. @rapzo - may 18th - 2016
    php 5.6
    const expressions sometimes constants are not
    just constants
    const arrays heheh told ya!
    ... Rest params via array! Awesome!
    ...$params and spreading
    exponentiation right to left, never forget!
    use syntax for functions and constants via
    namespaces
    Class::__debugInfo for class var_dump

    View Slide

  41. @rapzo - may 18th - 2016
    php 5.6
    const expressions sometimes constants are not
    just constants

    View Slide

  42. @rapzo - may 18th - 2016
    php 5.6
    const arrays heheh told ya!

    View Slide

  43. @rapzo - may 18th - 2016
    php 5.6
    ... Rest params via array! Awesome!

    View Slide

  44. @rapzo - may 18th - 2016
    php 5.6
    ...$params and spreading

    View Slide

  45. @rapzo - may 18th - 2016
    php 5.6
    exponentiation right to left, never forget!

    View Slide

  46. @rapzo - may 18th - 2016
    php 5.6
    use syntax for functions and constants via
    namespaces

    View Slide

  47. @rapzo - may 18th - 2016
    php 5.6
    Class::__debugInfo for class var_dump

    View Slide

  48. @rapzo - may 18th - 2016
    php 7.0
    types for function arguments
    more types for return declarations
    null or bust isset($a) ? $a : ‘a’ = $a ?? ‘a’
    spaceship op echo -1 <=> 1
    good ol’define for arrays
    anonymous classes fire and forget!
    Closure::call() hello late closure calls
    assert() expectations, finally!
    use just got javascript’d use \some\{A,B,C}

    View Slide

  49. @rapzo - may 18th - 2016
    php 7.0
    types for function arguments

    View Slide

  50. @rapzo - may 18th - 2016
    php 7.0
    more types for return declarations

    View Slide

  51. @rapzo - may 18th - 2016
    php 7.0
    null or bust isset($a) ? $a : ‘a’ = $a = $a ?? ‘a’

    View Slide

  52. @rapzo - may 18th - 2016
    php 7.0
    spaceship op echo -1 <=> 1

    View Slide

  53. @rapzo - may 18th - 2016
    php 7.0
    good ol’define for arrays

    View Slide

  54. @rapzo - may 18th - 2016
    php 7.0
    anonymous classes fire and forget!

    View Slide

  55. @rapzo - may 18th - 2016
    php 7.0
    Closure::call() hello late closure calls

    View Slide

  56. @rapzo - may 18th - 2016
    php 7.0
    assert() expectations, finally!

    View Slide

  57. @rapzo - may 18th - 2016
    php 7.0
    use just got javascript’d use \some\{A,B,C}

    View Slide

  58. @rapzo - may 18th - 2016
    HHVM
    php got sideways before announcing the 6th version,
    which made facebook develop its own virtual machine
    HHVM is a JIT compiler to bytecode and virtual
    machine that runs that bytecode

    View Slide

  59. @rapzo - may 18th - 2016
    HHVM
    HHVM is not a replacement for php although it has a
    new language, strong typed, called Hack
    HHVM supports php and is 99,9% with the 7th version

    View Slide

  60. @rapzo - may 18th - 2016
    HHVM and PHP
    In terms of performance, they are both fast
    In terms of deployment, HHVM is metal greedy

    View Slide

  61. @rapzo - may 18th - 2016
    Next time...
    The real talk about php apps, laravel, lumen and
    building something!

    View Slide

  62. thank you!

    View Slide

  63. ?

    View Slide