drupal7 enterprise web application framework

Upload: starssparkling

Post on 04-Apr-2018

227 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    1/66

    Drupal 7 as an enterprise webapplication framework

    Why as a developer you should use

    Drupal to build web applications?

    Klaus Harris

    DrupalCon Munich 2012

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    2/66

    Brief bio

    Who am I?

    Whats my Drupal story?

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    3/66

    Why this talk?

    1. Address some preconceptions that developers

    have about Drupal

    2. Why should I as a developer use Drupal 7

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    4/66

    Part 1

    Preconceptions

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    5/66

    Developer preconceptions

    1. Drupal is just a CMS

    2. Drupal isnt suitable for large enterprise sites

    3. Its old fashioned procedural code

    4. Ill have to learn some hideous plugin architecture

    5. Ill have to fit around the Drupal data model

    6. What I can do is limited (its just a CMS)

    7. Theming is difficult8. Drupal is slow

    9. I can write something like this but better

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    6/66

    1. Drupal is just a CMS

    We see a lot of comparisons like this:

    Drupal vs Joomla vs WordPress

    Open Source CMS Comparison

    CMS Comparison: Drupal, Joomla and Wordpress

    by Ashleigh Davis on 27 March 2011 | 6 Comments

    CMS-Battle: TYPO3 vs Drupalfight over 20 rounds

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    7/66

    But not this:

    Drupal vs Symfony

    Drupal vs

    Zend Framework

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    8/66

    And according to Wikipedia a web framework has:

    Web template system

    Caching

    Security

    Database access, mapping and configuration Url mapping

    Ajax

    Web services

    http://en.wikipedia.org/wiki/Web_application_framework

    http://en.wikipedia.org/wiki/Web_application_frameworkhttp://en.wikipedia.org/wiki/Web_application_framework
  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    9/66

    So why is Drupal is only seen as a CMS?

    Drupals origins

    Comparisons with Joomla, Wordpress and Typo3

    No comparisons with PHP frameworks like Zend

    Installable software on some hosters Very node centric data structure in < Drupal 7

    Admin interface (horror!)

    All those modules, it must be a CMS

    Ignorance

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    10/66

    node

    Teaser Full

    Drupal 6 was less flexible

    There was only really

    one content data

    type built in, namely

    the node.

    Nodes could be sub-

    typed and had only

    basic view modes. type

    A page is a

    node forexample.

    type type type

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    11/66

    Node Node revisions

    And that data lived in two tables

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    12/66

    Drupal 7 changes all this!

    Entity API, make:

    your own data table(s)

    different view modes

    sub-types fields

    AND

    you get all the goodneess

    you know from node API

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    13/66

    So now..

    node

    TeaserFull

    Entity

    user custom

    type

    Top 5

    RSS

    comment

    and

    type type type type

    TeaserFull

    RSS

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    14/66

    We arent tied to the Drupal database

    We can can override

    the data operation

    methods.

    meaning

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    15/66

    node

    Entity

    custom

    typetype type

    custom

    typetype

    Drupal

    DB

    Another

    DB

    Web

    service

    Our data can come from anywhere

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    16/66

    Add fields

    Control displayed fields depending on view mode

    Get the data into search and define which fields to

    index

    Use our own view modes

    Add custom sub-types

    Be data source agnostic

    Use all the hooks you are used to from nodes

    Entities are new in Drupal 7

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    17/66

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    18/66

    BUT!

    You arent tied to entities.

    If you want, just write your own CRUD code.

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    19/66

    What else makes Drupal more web framework?

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    20/66

    URL routing / menu

    Actions and triggers Queue mechanism

    Database API

    Caching Form API

    Theme system

    File API Roles and permissions

    and more..

    Internationalistion

    Web services

    Testing framework

    Contrib gold such as..

    Views

    Flag

    Rules

    Search API

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    21/66

    We use actions and triggers extensively

    Great fordecoupling

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    22/66

    2. Drupal isnt suitable for large enterprise sites

    Wrong!

    Look at big sites using it and explore case studies.

    Look at the architecture.

    http://www.examiner.com/http://www.acquia.com/resources/case-study/examinercom

    http://www.govtech.com/policy-management/Why-Big-Sites-Run-

    Drupal.html?page=1

    http://buytaert.net/tag/drupal-sites

    http://www.examiner.com/http://www.acquia.com/resources/case-study/examinercomhttp://www.govtech.com/policy-management/Why-Big-Sites-Run-Drupal.html?page=1http://www.govtech.com/policy-management/Why-Big-Sites-Run-Drupal.html?page=1http://buytaert.net/tag/drupal-siteshttp://buytaert.net/tag/drupal-siteshttp://buytaert.net/tag/drupal-siteshttp://buytaert.net/tag/drupal-siteshttp://www.govtech.com/policy-management/Why-Big-Sites-Run-Drupal.html?page=1http://www.govtech.com/policy-management/Why-Big-Sites-Run-Drupal.html?page=1http://www.govtech.com/policy-management/Why-Big-Sites-Run-Drupal.html?page=1http://www.govtech.com/policy-management/Why-Big-Sites-Run-Drupal.html?page=1http://www.govtech.com/policy-management/Why-Big-Sites-Run-Drupal.html?page=1http://www.govtech.com/policy-management/Why-Big-Sites-Run-Drupal.html?page=1http://www.govtech.com/policy-management/Why-Big-Sites-Run-Drupal.html?page=1http://www.govtech.com/policy-management/Why-Big-Sites-Run-Drupal.html?page=1http://www.govtech.com/policy-management/Why-Big-Sites-Run-Drupal.html?page=1http://www.govtech.com/policy-management/Why-Big-Sites-Run-Drupal.html?page=1http://www.govtech.com/policy-management/Why-Big-Sites-Run-Drupal.html?page=1http://www.acquia.com/resources/case-study/examinercomhttp://www.acquia.com/resources/case-study/examinercomhttp://www.acquia.com/resources/case-study/examinercomhttp://www.examiner.com/
  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    23/66

    3. Its old fashioned procedural code

    Its not all OOP

    True. Is that bad? *

    It has global variables

    True, live with it.

    There are so many arrays

    So what? Its PHP.

    * http://drupal.org/node/547518

    http://drupal.org/node/547518http://drupal.org/node/547518
  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    24/66

    4. Ill have to learn some hideous plugin architecture

    You will find it:

    Well architected

    Simple

    Powerful Intuitive

    Wrong!

    Yes!

    You will need to learn

    about hooks, overrides

    and preprocessing but..

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    25/66

    It is easy, you will like it

    For example, making a module:

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    26/66

    Menu hook

    and

    page callback

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    27/66

    Enable the new module.

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    28/66

    Simple!

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    29/66

    Lets make a block

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    30/66

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    31/66

    Simple!

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    32/66

    Form API is gold

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    33/66

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    34/66

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    35/66

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    36/66

    As a developer you will

    write a LOT of form code

    You should use a Form API

    that you like.

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    37/66

    5. Ill have to fit around the Drupal data model

    Wrong!

    Think of Drupal as a web framework with some default

    data structures set up for you.

    Create data structures via Entities

    Just make DB tables and write your own CRUD code

    Get data from entirely different DBs

    Get data from web services

    Power to you!

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    38/66

    6. What I can do is limited (its just a CMS)

    Wrong!

    Anything you can build with:

    Zend Framework Symfony

    and so on

    you can build with Drupal. With reduced development

    time!

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    39/66

    This search uses Zend Framework Lucene libraries.

    Dont forget! You can use Zend Framework

    components in Drupal too!

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    40/66

    7. Theming is difficult

    No its not.

    Themer - http://drupal.org/project/devel_themer

    Devel - http://drupal.org/project/devel

    Examples - http://drupal.org/project/examples

    Try simple starter theme

    Zen theme - http://drupal.org/project/zen Basic theme - http://drupal.org/project/basic

    http://drupal.org/project/devel_themerhttp://drupal.org/project/develhttp://drupal.org/project/exampleshttp://drupal.org/project/zenhttp://drupal.org/project/basichttp://drupal.org/project/basichttp://drupal.org/project/zenhttp://drupal.org/project/exampleshttp://drupal.org/project/develhttp://drupal.org/project/devel_themer
  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    41/66

    Theming

    is easy

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    42/66

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    43/66

    Renderable arrays, theming is even easier.

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    44/66

    Devel Themer module

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    45/66

    8. I can write something like this but better

    Really?

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    46/66

    9. Drupal is slow

    Full page caching

    Partial page caching e.g. blocks

    Static caching with function calls

    More efficient Entity loading Javascript aggregation

    CSS aggregation

    Master / Slave database configurations

    Different caching backends e.g. memcache

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    47/66

    Drupal performance greatly benefits from:

    An opcode cache like APC

    Memcache

    Check out the Drupal performance group:http://groups.drupal.org/high-performance

    and some performance related modules such as:

    http://drupal.org/project/memcache

    http://drupal.org/project/mongodb

    http://drupal.org/project/varnish

    http://groups.drupal.org/high-performancehttp://drupal.org/project/memcachehttp://drupal.org/project/mongodbhttp://drupal.org/project/varnishhttp://drupal.org/project/varnishhttp://drupal.org/project/mongodbhttp://drupal.org/project/memcachehttp://groups.drupal.org/high-performancehttp://groups.drupal.org/high-performancehttp://groups.drupal.org/high-performance
  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    48/66

    Worth looking here..

    on any module page.

    http://drupal.org/project/memcachehttp://drupal.org/project/memcache
  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    49/66

    Part 2

    Why should I as a developer useDrupal 7?

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    50/66

    1. What is good about coding Drupal 7?

    2. What should I be aware of?

    3. What mindset change do I need?

    4. Where do I go from here?

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    51/66

    1. What is good about coding Drupal 7?

    It is amazing what you can buildjustwith modules

    Rapid results

    Fully featured

    Code organisation Community and resources

    Theres a module for that

    Really nice APIs Developer tools

    2 What should I be aware of?

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    52/66

    2. What should I be aware of?

    Shock!!

    Zend Framework Drupal

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    53/66

    Organising code

    Up to you

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    54/66

    Configuration

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    55/66

    And..

    Works the same

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    56/66

    Deployment can be easier and trickier

    Easier through hooks and install pofiles.

    Trickier with configuration in the DB. Explore

    Features module.

    Flush the theme registry after theme changes

    Flush the menu registry after menu changes

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    57/66

    3. What mindset change do I need?

    You will combine modules AND custom code.

    Dont look for MVC, its more PAC *

    Dont look for a Zend / Symfony file structure

    Understand OO principles in the API ** and see past

    the procedural code. Embrace the Drupal way

    *

    http://www.garfieldtech.com/blog/mvc-vs-pac

    http://www.dossier-andreas.net/software_architecture/pac.html

    ** http://drupal.org/node/547518

    http://www.garfieldtech.com/blog/mvc-vs-pachttp://www.dossier-andreas.net/software_architecture/pac.htmlhttp://drupal.org/node/547518http://drupal.org/node/547518http://www.dossier-andreas.net/software_architecture/pac.htmlhttp://www.dossier-andreas.net/software_architecture/pac.htmlhttp://www.dossier-andreas.net/software_architecture/pac.htmlhttp://www.garfieldtech.com/blog/mvc-vs-pachttp://www.garfieldtech.com/blog/mvc-vs-pachttp://www.garfieldtech.com/blog/mvc-vs-pachttp://www.garfieldtech.com/blog/mvc-vs-pachttp://www.garfieldtech.com/blog/mvc-vs-pac
  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    58/66

    4. Where do I go from here?

    Explore Drupal.org

    Buy a book

    Who uses Drupal?

    Experiment Install Drupal

    Try some cookbook site

    builds

    Experiment with programming

    devel, drush, schema, devel_themer modules

    Explore the examples module

    Write a module

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    59/66

    Where could you use Drupal to get started?

    Personal site

    An intranet tool e.g. wiki / bug tracker / CRM

    New business project

    Part of a business presence

    Or a hybrid form

    The trick is to gain experience.

    I started with Drupal via a hybrid model..

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    60/66

    DrupalAn established B2Cwebsite News, help

    & FAQ

    Main

    DBMain

    DBs

    Drupal

    DB

    IntranetInternet

    Views

    Multi-lingual content for news,

    help and FAQs built in Drupal.

    I lik d D l h b il i f

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    61/66

    I liked Drupal so much we built on it for a startup

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    62/66

    It was a good decision

    and is fun!

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    63/66

    Thank you for listening

    Klaus Harris

    [email protected]

    www.distribly.com

    mailto:[email protected]://www.distribly.com/http://www.distribly.com/mailto:[email protected]
  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    64/66

    Appendix

    Some good books

    Drupal 6

    Using Drupal - First edition 1, O'Reilly PressPro Drupal 6 Development - Second Edition Apress

    Drupal 7

    Drupal 7 Module Development - Packt

    Pro Drupal 7 Development, Apress

    The Definitive Guide to Drupal 7 - Apress

  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    65/66

    Some links

    http://drupal.org

    Developer modules

    http://drupal.org/project/admin_menuhttp://drupal.org/project/devel

    http://drupal.org/project/devel_themer

    http://drupal.org/project/schema

    http://drupal.org/project/drush

    http://drupal.org/project/examples

    http://drupal.org/http://drupal.org/project/admin_menuhttp://drupal.org/project/develhttp://drupal.org/project/devel_themerhttp://drupal.org/project/schemahttp://drupal.org/project/drushhttp://drupal.org/project/exampleshttp://drupal.org/project/exampleshttp://drupal.org/project/drushhttp://drupal.org/project/schemahttp://drupal.org/project/devel_themerhttp://drupal.org/project/develhttp://drupal.org/project/admin_menuhttp://drupal.org/
  • 7/30/2019 Drupal7 Enterprise Web Application Framework

    66/66