45

“Drupal is written in PHP, which is uttterly offensive to people.”

  • Upload
    garnet

  • View
    31

  • Download
    0

Embed Size (px)

DESCRIPTION

H o r r i b l e T r u t h 1. “Drupal is written in PHP, which is uttterly offensive to people.”. H o r r i b l e T r u t h 2. “Drupal loads too much code” -rasmus. Is Drupal too Modular?. H o r r i b l e T r u t h 4. “Drupal is basically a 404 page to which you can add modules””. - PowerPoint PPT Presentation

Citation preview

Page 1: “Drupal is written in PHP, which is uttterly offensive to people.”
Page 2: “Drupal is written in PHP, which is uttterly offensive to people.”
Page 3: “Drupal is written in PHP, which is uttterly offensive to people.”

“Drupal is written in PHP, which is

uttterly offensive to people.”

H o r r i b l e T r u t h 1

Page 4: “Drupal is written in PHP, which is uttterly offensive to people.”
Page 5: “Drupal is written in PHP, which is uttterly offensive to people.”

“Drupal loads too much

code”

-rasmus

H o r r i b l e T r u t h 2

Page 6: “Drupal is written in PHP, which is uttterly offensive to people.”

Is Drupal too Modular?

Page 7: “Drupal is written in PHP, which is uttterly offensive to people.”

“Drupal is basically a 404 page to

which you can add modules””

H o r r i b l e T r u t h 4

Page 8: “Drupal is written in PHP, which is uttterly offensive to people.”

drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

index.phpincludes/bootstrap.inc - load necessary functionsdrupal_page_header() starts timer, sets up caching, module calloutincludes/common.inc - utility functions such as path formatting functions, form generation and validation, etc. fix_gpc_magic() sets $status 404 switch - case Not Found case Access Denied drupal_page_footer()

Page 9: “Drupal is written in PHP, which is uttterly offensive to people.”

drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

drupal_load()drupal_not_found();drupal_access_denied();drupal_site_offline();

$return = menu_execute_active_handler();print theme('page', $return);

drupal_page_footer();

Page 10: “Drupal is written in PHP, which is uttterly offensive to people.”

What's on the menu api?

MENU_CALLBACK

MENU_DEFAULT_LOCAL_TASK

MENU_LOCAL_TASK

MENU_MAX_DEPTH

MENU_MAX_PARTS

MENU_NORMAL_ITEM

MENU_SUGGESTED_ITEM

MENU_CALLBACK

MENU_DEFAULT_LOCAL_TASK

MENU_LOCAL_TASK

MENU_MAX_DEPTH

MENU_MAX_PARTS

MENU_NORMAL_ITEM

MENU_SUGGESTED_ITEM

Page 11: “Drupal is written in PHP, which is uttterly offensive to people.”

Scream API

Page 12: “Drupal is written in PHP, which is uttterly offensive to people.”

The Dreaded Hooks of Torture

H o r r i b l e T r u t h 7

Page 13: “Drupal is written in PHP, which is uttterly offensive to people.”

Hooks of Torture

• to implement a hook, create a function that 'extends' hooks into an existing hook (“hook function”)

• not functions but can be overloaded

• call user function array used to make dynamic function calls

Page 14: “Drupal is written in PHP, which is uttterly offensive to people.”

module_invoke_all

<?phpfunction module_invoke_all() { $args = func_get_args(); $hook = $args[0]; unset($args[0]); $return = array(); foreach (module_implements($hook) as $module) { $function = $module .'_'. $hook; $result = call_user_func_array($function, $args); if (isset($result) && is_array($result)) { $return = array_merge_recursive($return, $result); } else if (isset($result)) { $return[] = $result; } }

return $return;}?>

Page 15: “Drupal is written in PHP, which is uttterly offensive to people.”

hook_admin

/** * channels_admin * implements hook_admin * Provides channels admin form to save settings for the following fields: * */function channels_admin() { $form['channels'] = array( '#type' => 'textfield', '#title' => t('Channel'), '#default_value' => variable_get('channels', ''), '#size' => 25, '#maxlength' => 128, '#description' => t("channel_theme"), '#required' => TRUE, ); return system_settings_form($form);}

Page 16: “Drupal is written in PHP, which is uttterly offensive to people.”

hook_perms

/** * Implements hook_perm(). */function channels_perm() { return array( 'access channel content', 'administer channels', );}

Page 17: “Drupal is written in PHP, which is uttterly offensive to people.”

hook_menu

/** * Implements hook_menu(). anne/function channels_menu() { $items = array(); $items['admin/settings/channels'] = array( 'title' => 'channel settings', 'description' => 'select channel', 'page callback' => 'drupal_get_form', 'page arguments' => array('channels_admin'), 'access arguments' => array('administer channels'), 'type' => MENU_NORMAL_ITEM, ); return $items;}

Page 18: “Drupal is written in PHP, which is uttterly offensive to people.”

hook_block

/** * Implementation of hook_block(). */function channels_block($op = 'list', $delta = 0, $edit = array()) { switch ($op) { case 'list': $blocks[0]['info'] = t('current_channel'); return $blocks; case 'view': $totals = _channels_get_theme(); if (!empty($webstream)) { $content = theme('channels_current_theme', $webstream); } $blocks['subject'] = t('You're What's On!'); $blocks['content'] = $content; return $blocks; }

Page 19: “Drupal is written in PHP, which is uttterly offensive to people.”

hook_menu_alter

/** Implementation of hook_menu_alter(). */

function noaccess_menu_alter(&$items) { $items['node']['access arguments'] = array('access node path');

}

/** Implementation of hook_perm(). */

function noaccess_perm() { return array('access node path');}

Page 20: “Drupal is written in PHP, which is uttterly offensive to people.”

Hook Soup

Page 21: “Drupal is written in PHP, which is uttterly offensive to people.”

Does Drupal have a Learning Curve...

Page 22: “Drupal is written in PHP, which is uttterly offensive to people.”

…or a Learning Brick Wall ?

Page 23: “Drupal is written in PHP, which is uttterly offensive to people.”
Page 24: “Drupal is written in PHP, which is uttterly offensive to people.”

“Community Plumbing”

Page 25: “Drupal is written in PHP, which is uttterly offensive to people.”

Drupal is a Pushme - Pullyou

Framework!Product!

Page 26: “Drupal is written in PHP, which is uttterly offensive to people.”

What's aNode?

Field API

Page 27: “Drupal is written in PHP, which is uttterly offensive to people.”

“Drupal Isn't 'Classy”'?

H o r r i b l e T r u t h 9

Page 28: “Drupal is written in PHP, which is uttterly offensive to people.”

“Drupal isn't Object

Oriented?”

H o r r i b l e T r u t h 10

Page 29: “Drupal is written in PHP, which is uttterly offensive to people.”

Drupal Design PatternDRUPAL DESIGN PATTERN

Page 30: “Drupal is written in PHP, which is uttterly offensive to people.”

Drupal Design PatternREALITY CHECK.

Page 31: “Drupal is written in PHP, which is uttterly offensive to people.”

Drupal Anti-Pattern

“Load Everything then

Cherry Pick What You Need.”

Page 32: “Drupal is written in PHP, which is uttterly offensive to people.”

Drupal Encourages

Slavery

H o r r i b l e T r u t h 11

Page 33: “Drupal is written in PHP, which is uttterly offensive to people.”

Making Drupal “Slave Safe!”

Page 34: “Drupal is written in PHP, which is uttterly offensive to people.”

Actions* & Triggers

*(not slave safe)

Page 35: “Drupal is written in PHP, which is uttterly offensive to people.”

Database TNG

Page 36: “Drupal is written in PHP, which is uttterly offensive to people.”
Page 37: “Drupal is written in PHP, which is uttterly offensive to people.”

Performance & Scaling

Sample Metrics from a large Drupal site:

50 million page views per month

6.5 million site visitors per month

150,000 page views per hour

load tests to levels of greater than 500,000 page views per hour

Drupal.org delivers approximately 1M/day/month

Page 38: “Drupal is written in PHP, which is uttterly offensive to people.”

Object CachingAPC

Advantages Low latency No need to serialize/unserialize items Scales perfectly with more web servers

Disadvantages No enforced consistency across multiple web servers Cache is not shared; each web server must generate each item

memcached

Advantages Consistent across multiple web servers Cache is shared across all web servers; items only need to be

generated once

Disadvantages High latency Requires serializing/unserializing items Easily shards data across multiple web servers, but is still a big,

shared cache

Page 39: “Drupal is written in PHP, which is uttterly offensive to people.”

Cache Headers

Page 40: “Drupal is written in PHP, which is uttterly offensive to people.”
Page 41: “Drupal is written in PHP, which is uttterly offensive to people.”

* Download and enable devel module: drush dl devel drush enable devel * Run cron: drush cron * Refresh modules and core updates informartion: drush refresh * Take a snapshot of the DB: drush sql dump > mydb.sql * Open a mysql console for running SQL commands into

Drupal DB: drush sql cli * Clear Drupal cache: drush cache clear

drush

Page 42: “Drupal is written in PHP, which is uttterly offensive to people.”

drush

Page 43: “Drupal is written in PHP, which is uttterly offensive to people.”

drush_makecore = "7.x"

projects[] = "drupal"

projects[] = "acquia_connector"

projects[apachesolr][download][type] = "cvs"

projects[apachesolr][download][module] = "contributions/modules/apachesolr"

projects[apachesolr][download][revision] = "DRUPAL-7--0"

projects[acquia_search][type] = "module"

projects[acquia_search][download][type] = "svn"

projects[acquia_search][download][url] = "https://svn.acquia.com/drupal/branches/1.x-

7.x/modules/acquia/acquia_search/"

libraries[SolrPhpClient][download][type] = "get"

libraries[SolrPhpClient][download][url] =

"http://solr-php-client.googlecode.com/files/SolrPhpClient.r22.2009-11-09.tgz"libraries[SolrPhpClient][destination] = "modules/apachesolr"

Page 44: “Drupal is written in PHP, which is uttterly offensive to people.”

touch ~/.logrotate.state ~/.logrotate.config

emacs ~/.logrotate.config

~/backup/dev.sql.gz { rotate 7 daily nocompress nocopytruncate postrotate /usr/bin/drush -r ~/web.root.org/web/ sql dump | gzip > ~/backup/dev.sql.gz

endscript}

/usr/bin/drush -r ~/web.root.org/web/ sql dump | gzip > ~/backup/dev.sql.gz

Automated Backup

Page 45: “Drupal is written in PHP, which is uttterly offensive to people.”