Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Drupal: Rejoining the Herd

Drupal: Rejoining the Herd

Oliver Davies

June 11, 2016
Tweet

More Decks by Oliver Davies

Other Decks in Technology

Transcript

  1. Drupal: Re-joining
    the Herd
    PHP South Coast 2016
    Oliver Davies / @opdavies

    View Slide

  2. Drupal: Getting o
    the Island
    PHP South Coast 2016
    Oliver Davies / @opdavies

    View Slide

  3. Drupal: Re-joining
    the Herd
    PHP South Coast 2016
    Oliver Davies / @opdavies

    View Slide

  4. @opdavies
    Senior Drupal Developer at
    Former Drupal Association employee
    Symfony hobbyist
    Drupal Bristol organiser, PHPSW and
    DrupalCamp Bristol co-organiser
    First PHP conference!
    Appnovation
    Technologies

    View Slide

  5. Purpose
    If you're new to Drupal, go and try it
    If you've used it before, re-try it

    View Slide

  6. View Slide

  7. About Drupal
    Drupal is an open source, PHP content management
    system
    16 years old
    Drupal 8 was released in November 2015
    Non-BC changes between major versions
    Mostly procedural code prior to D8
    Drupalisms

    View Slide

  8. Entities(ish)
    Everything uses s
    t
    d
    C
    l
    a
    s
    s
    No consistency between models

    View Slide

  9. Hooks
    /
    / h
    e
    l
    l
    o
    .
    m
    o
    d
    u
    l
    e
    /
    *
    *
    * I
    m
    p
    l
    e
    m
    e
    n
    t
    s h
    o
    o
    k
    _
    m
    e
    n
    u
    (
    )
    *
    /
    f
    u
    n
    c
    t
    i
    o
    n h
    e
    l
    l
    o
    _
    m
    e
    n
    u
    (
    ) {
    $
    i
    t
    e
    m
    s
    [
    '
    h
    e
    l
    l
    o
    -
    w
    o
    r
    l
    d
    '
    ] = a
    r
    r
    a
    y
    (
    .
    .
    .
    )
    ;
    r
    e
    t
    u
    r
    n $
    i
    t
    e
    m
    s
    ;
    }

    View Slide

  10. Theme functions
    $
    i
    t
    e
    m
    s
    [
    l
    (
    '
    F
    o
    o
    '
    , '
    f
    o
    o
    '
    )
    ,
    l
    (
    '
    B
    a
    r
    '
    , '
    b
    a
    r
    '
    )
    ,
    ]
    ;
    r
    e
    t
    u
    r
    n t
    h
    e
    m
    e
    (
    '
    i
    t
    e
    m
    _
    l
    i
    s
    t
    '
    , [
    '
    i
    t
    e
    m
    s
    ' =
    > $
    i
    t
    e
    m
    s
    ]
    )
    ;
    <
    u
    l c
    l
    a
    s
    s
    =
    "
    i
    t
    e
    m
    -
    l
    i
    s
    t
    "
    >
    <
    l
    i
    >
    <
    a h
    r
    e
    f
    =
    "
    f
    o
    o
    "
    >
    F
    o
    o
    <
    /
    a
    >
    <
    /
    l
    i
    >
    <
    l
    i
    >
    <
    a h
    r
    e
    f
    =
    "
    b
    a
    r
    "
    >
    B
    a
    r
    <
    /
    a
    >
    <
    /
    l
    i
    >
    <
    /
    u
    l
    >

    View Slide

  11. View Slide

  12. http://www.ekino.com/wp-content/uploads/2013/09/drupal8-meets-symfony.jpg

    View Slide

  13. http://jmolivas.com/slides/drupalcon2015bogota/speeding-up-drupal-8-development-using-drupal-
    console/assets/images/larry-crell.jpg

    View Slide

  14. Symfony
    Core developed using Symfony components
    Minimum PHP version requirement
    PHP code in classes
    No more functions (almost)
    Namespaces
    PSR-0 PSR-4 Autoloading
    Dependency injection
    Full test coverage
    Consistency!

    View Slide

  15. Symfony components
    ClassLoader
    Console
    CssSelector
    DependencyInjection
    EventDispatcher
    HttpFoundation
    HttpKernel
    Process
    Routing
    Serializer
    Translation
    Validator
    Yaml
    http://symfony.com/projects/drupal

    View Slide

  16. YAML
    example.info (D7)
    n
    a
    m
    e = E
    x
    a
    m
    p
    l
    e
    c
    o
    r
    e = 7
    .
    x
    p
    a
    c
    k
    a
    g
    e = C
    u
    s
    t
    o
    m
    d
    e
    p
    e
    n
    d
    e
    n
    c
    i
    e
    s
    [
    ] = e
    n
    t
    i
    t
    y
    f
    i
    l
    e
    s
    [
    ] = a
    .
    i
    n
    c
    f
    i
    l
    e
    s
    [
    ] = b
    .
    i
    n
    c
    example.info.yml (D8)
    n
    a
    m
    e
    : E
    x
    a
    m
    p
    l
    e
    t
    y
    p
    e
    : m
    o
    d
    u
    l
    e
    c
    o
    r
    e
    : 8
    .
    x
    p
    a
    c
    k
    a
    g
    e
    : C
    u
    s
    t
    o
    m
    d
    e
    p
    e
    n
    d
    e
    n
    c
    i
    e
    s
    :
    - e
    n
    t
    i
    t
    y

    View Slide

  17. Routing (D7)
    hello.module
    f
    u
    n
    c
    t
    i
    o
    n h
    e
    l
    l
    o
    _
    m
    e
    n
    u
    (
    ) {
    $
    i
    t
    e
    m
    s
    [
    '
    h
    e
    l
    l
    o
    -
    w
    o
    r
    l
    d
    '
    ] = [
    '
    t
    i
    t
    l
    e
    ' =
    > '
    H
    e
    l
    l
    o
    , P
    H
    P
    S
    C
    '
    ,
    '
    p
    a
    g
    e c
    a
    l
    l
    b
    a
    c
    k
    ' =
    > '
    h
    e
    l
    l
    o
    _
    p
    a
    g
    e
    _
    c
    a
    l
    l
    b
    a
    c
    k
    '
    ,
    '
    a
    c
    c
    e
    s
    s a
    r
    g
    u
    m
    e
    n
    t
    s
    ' =
    > [
    '
    a
    c
    c
    e
    s
    s c
    o
    n
    t
    e
    n
    t
    '
    ]
    ,
    ]
    ;
    r
    e
    t
    u
    r
    n $
    i
    t
    e
    m
    s
    ;
    }

    View Slide

  18. Routing (D8)
    hello.routing.yml
    h
    e
    l
    l
    o
    .
    v
    i
    e
    w
    :
    p
    a
    t
    h
    : /
    h
    e
    l
    l
    o
    -
    w
    o
    r
    l
    d
    d
    e
    f
    a
    u
    l
    t
    s
    :
    _
    t
    i
    t
    l
    e
    : '
    H
    e
    l
    l
    o
    , P
    H
    P
    S
    C
    '
    _
    c
    o
    n
    t
    r
    o
    l
    l
    e
    r
    : '
    \
    D
    r
    u
    p
    a
    l
    \
    h
    e
    l
    l
    o
    \
    C
    o
    n
    t
    r
    o
    l
    l
    e
    r
    \
    P
    a
    g
    e
    C
    o
    n
    t
    r
    o
    l
    l
    e
    r
    :
    :
    h
    e
    l
    l
    o
    V
    i
    e
    w
    '

    View Slide

  19. Annotations
    Used in some places - e.g. plugin system

    View Slide

  20. Twig
    Default theme engine in D8
    Replaces phptemplate
    No more database queries in templates
    No more theme functions

    View Slide

  21. Not Invented Here

    View Slide

  22. Not Invented Here

    View Slide

  23. Proudly found elsewhere
    jQuery *
    Symfony
    Symfony CMF
    CKEditor
    Zend
    Composer
    Stack
    Guzzle
    Twig
    PhpUnit
    http://cgit.drupalcode.org/drupal/tree/core/composer.json

    View Slide

  24. Composer
    Drupal 8 using Composer for dependency
    management and autoloading
    Better Composer support since 8.1
    Composer integration on Drupal.org
    Drupal Composer projectroject template
    Project template
    Drupal Packagist

    View Slide

  25. Drupal via Composer
    "
    r
    e
    p
    o
    s
    i
    t
    o
    r
    i
    e
    s
    "
    : [
    {
    "
    t
    y
    p
    e
    "
    : "
    c
    o
    m
    p
    o
    s
    e
    r
    "
    ,
    "
    u
    r
    l
    "
    : "
    h
    t
    t
    p
    s
    :
    /
    /
    p
    a
    c
    k
    a
    g
    e
    s
    .
    d
    r
    u
    p
    a
    l
    .
    o
    r
    g
    /
    8
    "
    }
    ]
    ,
    r
    e
    q
    u
    i
    r
    e
    : {
    "
    d
    r
    u
    p
    a
    l
    /
    c
    o
    r
    e
    "
    : "
    ~
    8
    .
    0
    "
    }
    ,
    .
    .
    .
    https://github.com/platformsh/platformsh-example-drupal/blob/8.x/composer.json

    View Slide

  26. Contrib
    - Symfony WebPro ler Bundle as a Drupal 8
    module
    - adds a GUI for Composer
    dependencies
    - PSR-4 support for Drupal 7
    Web Pro ler
    Composer Manager
    xautoload

    View Slide

  27. Libraries rst
    Non-Drupal problems being xed
    outside of Drupal
    Framework agnostic PHP libraries
    Better exposure
    Production tested code
    Allows for backports

    View Slide

  28. Libraries rst

    View Slide

  29. Libraries First

    View Slide

  30. Drupal Console
    A CLI tool for generating Drupal code and
    interacting with Drupal 8 websites
    Based on Symfony Console component
    PSR-2 coding style, outputs Drupal code
    style
    http://drupalconsole.com

    View Slide

  31. View Slide

  32. Going forward
    Semantic versioning
    Feature releases every 6
    months
    https://www.drupal.org/core/release-cycle-overview

    View Slide

  33. More to do?
    Still some Drupalisms
    PSR-2
    GitHub/Packagist
    Drupal CI

    View Slide

  34. In Summary
    Lowered the barrier to entry for PHP Developers
    Made me a better Developer
    More transferable knowledge and skills
    Changed perspective

    View Slide

  35. Links
    drupal.org
    drupal.org/8
    drupal-composer.org

    View Slide

  36. Questions?

    View Slide

  37. DrupalCamp Bristol
    22nd - 24th July
    phpsc-fri - £20 off the business day
    phpsc-sat - £5 off the conference day
    https://www.drupalcampbristol.co.uk

    View Slide

  38. Feedback
    Joind.in: https://joind.in/talk/41d0f
    Twitter: @opdavies

    View Slide