SlideShare a Scribd company logo
1 of 39
Download to read offline
An Introduction to
Drupal Architecture
JohnVanDyk
DrupalCamp Des Moines, Iowa
September 17, 2011
1
Apache IIS
OS
Nginx
PHP 5.2.5
Stack with OS, webserver and PHP. Most people use mod_php
but deployments with engineers at the helm sometimes use
FastCGI. PHP 5.2.4 with the 5.2.5 security backport is fine too
(Ubuntu 8.0.4).
2
Apache IIS
OS
Nginx
hash
date SimpleXMLjson
dom SPLpcre
filter xmlsession
gd pdo
pdo_mysql
PHP
Some PHP extensions are required.
3
Apache IIS
OS
Nginx
PHP 5.2.5
MySQL
5.0.15
MariaDB
5.1.44
Database.
4
Apache IIS
OS
Nginx
PHP 5.2.5
MySQL
5.0.15
MariaDB
5.1.44
Drupal 7
Drupal sits atop the stack.
5
Apache IIS
OS
Nginx
PHP 5.2.5
MySQL
5.0.15
MariaDB
5.1.44
Drupal 7
Varnish
Varnish can be added to the front end for fast RAM-based
response to anonymous users.
6
Apache
Load
Balancer
PHP 5.2.5
MySQL
Drupal 7
OS
OS
Apache
PHP 5.2.5
Drupal 7
OS
Apache
PHP 5.2.5
Drupal 7
OS
Apache
PHP 5.2.5
Drupal 7
OS
Apache
PHP 5.2.5
Drupal 7
OS
Apache
PHP 5.2.5
Drupal 7
OS
Apache
PHP 5.2.5
Drupal 7
OS
Apache
PHP 5.2.5
Drupal 7
OS
Apache
PHP 5.2.5
Drupal 7
OS
Apache
PHP 5.2.5
Drupal 7
OS
Apache
PHP
Drupal 7
OS
Webheads can be scaled out.
7
Apache
Load
Balancer
PHP 5.2.5
MySQL
Master
Drupal 7
OS
OS
Apache
PHP 5.2.5
Drupal 7
OS
Apache
PHP 5.2.5
Drupal 7
OS
Apache
PHP 5.2.5
Drupal 7
OS
Apache
PHP 5.2.5
Drupal 7
OS
Apache
PHP 5.2.5
Drupal 7
OS
Apache
PHP 5.2.5
Drupal 7
OS
Apache
PHP 5.2.5
Drupal 7
OS
Apache
PHP 5.2.5
Drupal 7
OS
Apache
PHP 5.2.5
Drupal 7
OS
Apache
PHP
Drupal 7
OS
MySQL
Slaves
OS
MySQL
Slaves
OS
MySQL
Slaves
OS
MySQL
Slaves
OS
Databases can be scaled out. Show master-slave but master-
master is also a possibility. See http://www.jochus.be/site/
2011-01-13/drupal/drupal-master-master-replication-architecture
for an example.
8
Source: Nate Haug, Lullabot Scaling the Grammys. DrupalCamp Denver 2010.
214 million hits in six hours at peak. Database load: 5%. Apache
load: 1%.
9
You will not hack core.
You should only modify the locations shown in green. Modifying
the other files will inevitably lead to grief.
10
Development Site
Local settings, including database connection info, are in sites/all/
dev.local.
11
Live Site
On the live site settings are in a site-specific directory.
12
http://www.doodlepress.co.uk/item/1460
Drupal 7 Architecture
Drupal architecture. Each include file has a different color and
their interrelationships are shown. Uh...just kidding.
13
Browser request: GET /node/1
Bootstrap (includes/bootstrap.inc)
- brings session, database, variables online
Menu System (router)
- maps URL to a function
- checks access control
- may bring functions into scope
- calls function to build page data structure
- calls function to theme page (look and feel)
- page returned to client
It is important for a developer to understand the sequence of
events that occur when a request is processed by Drupal.
14
/index.php?q=node/1
/node/1
mod_rewrite in .htaccess
$_GET['q'] will contain 'node/1'
A typical request starts with mod_rewrite.
15
index.php
menu system
Which function should this path be mapped to?
$items['node/%node'] = array(
'page callback' => 'node_page_view',
'page arguments' => array(1),
'access callback' => 'node_access',
'access arguments' => array('view', 1),
);
index.php invokes the menu system, which handles much more
than menus. The menu item that maps to node/1 can be found in
node.module.
16
index.php
menu system
Does this user have permission to access this path?
$items['node/%node'] = array(
'page callback' => 'node_page_view',
'page arguments' => array(1),
'access callback' => 'node_access',
'access arguments' => array('view', 1),
);
node.module tells the menu system to invoke a function
(node_access()) to determine whether the current user has
permission.
17
index.php
menu system node.module
/**
* Menu callback; view a single node.
*/
function node_page_view($node) {
...
}
The page callback for the path node/1 is 'node_page_view'. That's
the name of the function that is called if the user has permission
to view the page.
18
index.php
menu system node.module
hook_node_load()
book.module
comment.module
forum.module
user.module
book_node_load()
comment_node_load()
forum_node_load()
user_node_load()
Other modules have a say in the loading of the node object. Many
of these hooks (better thought of as "events") happen during the
building of a page.
19
index.php
menu system
A large array with the node's data structure is returned to the
menu system.
20
index.php
menu system node.module
hook_node_view_alter()
drupalcorn.module
drupalcorn_node_view_alter()
Other modules may alter the final data structure. We've seen
three common patterns that pervade Drupal: (1) hooks allow other
modules to respond to events; (2) Drupal uses large structured
arrays, and (3) other modules may alter these arrays once built.
21
index.php
menu system
delivery callback
drupal_render_page()
theme()
page.tpl.php
node.tpl.php
block.tpl.php
The menu system passes the structure array to a delivery
callback which turns the array into HTML by rendering it; that is,
passing it through Drupal's template engine. Template files
(.tpl.php, pronounced "tipple-fipp") in the current theme are used
to create the HTML.
22
index.php
The HTML is then returned to the browser.
23
Common Library Database API
Fields API
Entity API
N
o
d
e
s
U
s
e
r
s
T
a
x
o
n
o
m
y
C
o
m
m
e
n
t
s
Form
API
Menu
API
Block
API
Locali
zation
Views
Template Preprocessing
Theme
Modules add
functionality here
Block diagram if you need a mental model. This doesnʼt have
nearly enough dimensions to describe what actually happens. If
you asked 5 developers to make Drupal block diagrams, you'd get
5 different diagrams. Hopefully this one helps someone.
24
"Entities"
Node: a piece of content
User: a user account
Taxonomy: categories for tagging/classification
Comment: content with a parent
25
An Entity has Bundles
Node
Title
Body
Title
Body
Page
An entity can be thought of as a base object, and bundles are
subclasses. For example, a node is an entity while the bundle of
fields that make up a page are a type of node.
26
An Entity has Bundles
Title
Body
Page
Title
Body
Article
Tags
Image
These are types of nodes. Each has a bundle of fields.
27
A Bundle has Fields
Title
Body
Article
Tags
Image
text_long
text_with_summary
taxonomy_term_reference
image
And each field has a type.
28
Not SQL Fields
Title
Body
Article
Tags
Image
text_with_summary
taxonomy_term_reference
These are more than SQL fields. text_with_summary
autogenerates a summary. taxonomy_term_reference splits
multiple tags into separate records. These are Drupal fields.
29
In the Real World
"Entity" = node | user | comment | taxonomy
"Bundle" = "Content Type"
You assemble content types from fields using the UI.
Part of the conversation with your client!
Nobody says "let's create a new Node Bundle and call it Bug
Report".
30
Before Building a Site
• What content types and fields?
• How will the data get in? (Forms)
• How will the data get out? (Views)
• Who may create/view/delete data? (Permissions)
• What additional functionality? (Modules)
• How can we make it pretty? (Theming)
Questions to map client needs to Drupal concepts.
31
http://api.drupal.org
Your home for API-related searches.
32
http://drupal.org/project/examples
Simple implementations of APIs. You can base your own work on
these examples.
33
Bonus!
Two tools I use all the time.
34
Defeating the
White Screen of Death
error_log = /var/log/php/error.log
Define PHP error log in php.ini:
I close with two essential tools. First, don't be frightened by the
WSOD.
35
tail -f /var/log/php/error.log
[07-Sep-2011 16:25:02] PHP Fatal error:
Call to undefined function int() in
bgstat.module on line 41
Watch the error log to find out what’s going on:
PHP will always tell you what went wrong in its log. If you've
defined a PHP error log in php.ini, you can watch it in real time
with tail -f.
36
Where is the code?
egrep -rn searchstring .
Quickly search the codebase for a function:
Second, don't be overwhelmed with the codebase. egrep and
pipes can help you find where functions live and where things
happen. Example: where are mail-related variables set?
37
egrep -rn mail . | grep variable_set
./includes/install.core.inc:1802:
variable_set('site_mail', $form_state['values']
['site_mail']);
./includes/install.core.inc:1813:
variable_set('update_notify_emails', array($form_state
['values']['account']['mail']));
./modules/openid/openid.test:323:
variable_set('user_email_verification',TRUE);
...
There we go. The codebase is like a rich porridge, waiting for you
to sift through and find the tasty lumps.
38
Thanks!
Hopefully these help create a big picture
of how Drupal works.This only scratches the surface.
Now get your debugger
working and explore Drupal core on your own!
39

More Related Content

What's hot

2 introduction-php-mvc-cakephp-m2-installation-slides
2 introduction-php-mvc-cakephp-m2-installation-slides2 introduction-php-mvc-cakephp-m2-installation-slides
2 introduction-php-mvc-cakephp-m2-installation-slidesMasterCode.vn
 
CakePHP 2.0 - It'll rock your world
CakePHP 2.0 - It'll rock your worldCakePHP 2.0 - It'll rock your world
CakePHP 2.0 - It'll rock your worldGraham Weldon
 
Development Setup of B-Translator
Development Setup of B-TranslatorDevelopment Setup of B-Translator
Development Setup of B-TranslatorDashamir Hoxha
 
BP204 It's Not Infernal: Dante's Nine Circles of XPages Heaven
BP204 It's Not Infernal: Dante's Nine Circles of XPages HeavenBP204 It's Not Infernal: Dante's Nine Circles of XPages Heaven
BP204 It's Not Infernal: Dante's Nine Circles of XPages HeavenMichael McGarel
 
Intoduction to Play Framework
Intoduction to Play FrameworkIntoduction to Play Framework
Intoduction to Play FrameworkKnoldus Inc.
 
LvivPy - Flask in details
LvivPy - Flask in detailsLvivPy - Flask in details
LvivPy - Flask in detailsMax Klymyshyn
 
Flask RESTful Flask HTTPAuth
Flask RESTful Flask HTTPAuthFlask RESTful Flask HTTPAuth
Flask RESTful Flask HTTPAuthEueung Mulyana
 
Django, What is it, Why is it cool?
Django, What is it, Why is it cool?Django, What is it, Why is it cool?
Django, What is it, Why is it cool?Tom Brander
 
3 introduction-php-mvc-cakephp-m3-getting-started-slides
3 introduction-php-mvc-cakephp-m3-getting-started-slides3 introduction-php-mvc-cakephp-m3-getting-started-slides
3 introduction-php-mvc-cakephp-m3-getting-started-slidesMasterCode.vn
 
Digital Fabrication Studio v.0.2: Information
Digital Fabrication Studio v.0.2: InformationDigital Fabrication Studio v.0.2: Information
Digital Fabrication Studio v.0.2: InformationMassimo Menichinelli
 
4 introduction-php-mvc-cakephp-m4-controllers-slides
4 introduction-php-mvc-cakephp-m4-controllers-slides4 introduction-php-mvc-cakephp-m4-controllers-slides
4 introduction-php-mvc-cakephp-m4-controllers-slidesMasterCode.vn
 
Drupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesDrupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesShabir Ahmad
 
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...Edureka!
 

What's hot (17)

dJango
dJangodJango
dJango
 
2 introduction-php-mvc-cakephp-m2-installation-slides
2 introduction-php-mvc-cakephp-m2-installation-slides2 introduction-php-mvc-cakephp-m2-installation-slides
2 introduction-php-mvc-cakephp-m2-installation-slides
 
Java Enterprise Edition
Java Enterprise EditionJava Enterprise Edition
Java Enterprise Edition
 
CakePHP 2.0 - It'll rock your world
CakePHP 2.0 - It'll rock your worldCakePHP 2.0 - It'll rock your world
CakePHP 2.0 - It'll rock your world
 
Development Setup of B-Translator
Development Setup of B-TranslatorDevelopment Setup of B-Translator
Development Setup of B-Translator
 
Flask Basics
Flask BasicsFlask Basics
Flask Basics
 
BP204 It's Not Infernal: Dante's Nine Circles of XPages Heaven
BP204 It's Not Infernal: Dante's Nine Circles of XPages HeavenBP204 It's Not Infernal: Dante's Nine Circles of XPages Heaven
BP204 It's Not Infernal: Dante's Nine Circles of XPages Heaven
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Intoduction to Play Framework
Intoduction to Play FrameworkIntoduction to Play Framework
Intoduction to Play Framework
 
LvivPy - Flask in details
LvivPy - Flask in detailsLvivPy - Flask in details
LvivPy - Flask in details
 
Flask RESTful Flask HTTPAuth
Flask RESTful Flask HTTPAuthFlask RESTful Flask HTTPAuth
Flask RESTful Flask HTTPAuth
 
Django, What is it, Why is it cool?
Django, What is it, Why is it cool?Django, What is it, Why is it cool?
Django, What is it, Why is it cool?
 
3 introduction-php-mvc-cakephp-m3-getting-started-slides
3 introduction-php-mvc-cakephp-m3-getting-started-slides3 introduction-php-mvc-cakephp-m3-getting-started-slides
3 introduction-php-mvc-cakephp-m3-getting-started-slides
 
Digital Fabrication Studio v.0.2: Information
Digital Fabrication Studio v.0.2: InformationDigital Fabrication Studio v.0.2: Information
Digital Fabrication Studio v.0.2: Information
 
4 introduction-php-mvc-cakephp-m4-controllers-slides
4 introduction-php-mvc-cakephp-m4-controllers-slides4 introduction-php-mvc-cakephp-m4-controllers-slides
4 introduction-php-mvc-cakephp-m4-controllers-slides
 
Drupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesDrupal 8 - Core and API Changes
Drupal 8 - Core and API Changes
 
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
 

Similar to Intro to drupal_7_architecture

Introduction To Drupal
Introduction To DrupalIntroduction To Drupal
Introduction To DrupalLauren Roth
 
Open erp technical_memento_v0.6.3_a4
Open erp technical_memento_v0.6.3_a4Open erp technical_memento_v0.6.3_a4
Open erp technical_memento_v0.6.3_a4openerpwiki
 
Custom module and theme development in Drupal7
Custom module and theme development in Drupal7Custom module and theme development in Drupal7
Custom module and theme development in Drupal7marif4pk
 
Open Source RAD with OpenERP 7.0
Open Source RAD with OpenERP 7.0Open Source RAD with OpenERP 7.0
Open Source RAD with OpenERP 7.0Quang Ngoc
 
A new tool for measuring performance in Drupal 8 - DrupalCamp London
A new tool for measuring performance in Drupal 8 - DrupalCamp LondonA new tool for measuring performance in Drupal 8 - DrupalCamp London
A new tool for measuring performance in Drupal 8 - DrupalCamp LondonLuca Lusso
 
OpenERP Technical Memento V0.7.3
OpenERP Technical Memento V0.7.3OpenERP Technical Memento V0.7.3
OpenERP Technical Memento V0.7.3Borni DHIFI
 
OpenERP Technical Memento
OpenERP Technical MementoOpenERP Technical Memento
OpenERP Technical MementoOdoo
 
13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS 13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS DrupalMumbai
 
PHP Frameworks and CodeIgniter
PHP Frameworks and CodeIgniterPHP Frameworks and CodeIgniter
PHP Frameworks and CodeIgniterKHALID C
 
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013Mack Hardy
 
Drupal Meetup Lisbon
Drupal Meetup LisbonDrupal Meetup Lisbon
Drupal Meetup LisbonPaulo Gomes
 
The power of mysqlnd plugins
The power of mysqlnd pluginsThe power of mysqlnd plugins
The power of mysqlnd pluginsUlf Wendel
 
Symfony2 Introduction Presentation
Symfony2 Introduction PresentationSymfony2 Introduction Presentation
Symfony2 Introduction PresentationNerd Tzanetopoulos
 
Артем Сыльчук - Хранение полей в Drupal. От CCK к FieldableEntityStorageContr...
Артем Сыльчук - Хранение полей в Drupal. От CCK к FieldableEntityStorageContr...Артем Сыльчук - Хранение полей в Drupal. От CCK к FieldableEntityStorageContr...
Артем Сыльчук - Хранение полей в Drupal. От CCK к FieldableEntityStorageContr...LEDC 2016
 

Similar to Intro to drupal_7_architecture (20)

Introduction To Drupal
Introduction To DrupalIntroduction To Drupal
Introduction To Drupal
 
Open erp technical_memento_v0.6.3_a4
Open erp technical_memento_v0.6.3_a4Open erp technical_memento_v0.6.3_a4
Open erp technical_memento_v0.6.3_a4
 
Custom module and theme development in Drupal7
Custom module and theme development in Drupal7Custom module and theme development in Drupal7
Custom module and theme development in Drupal7
 
Dn D Custom 1
Dn D Custom 1Dn D Custom 1
Dn D Custom 1
 
Dn D Custom 1
Dn D Custom 1Dn D Custom 1
Dn D Custom 1
 
cakephp UDUYKTHA (1)
cakephp UDUYKTHA (1)cakephp UDUYKTHA (1)
cakephp UDUYKTHA (1)
 
Open Source RAD with OpenERP 7.0
Open Source RAD with OpenERP 7.0Open Source RAD with OpenERP 7.0
Open Source RAD with OpenERP 7.0
 
A new tool for measuring performance in Drupal 8 - DrupalCamp London
A new tool for measuring performance in Drupal 8 - DrupalCamp LondonA new tool for measuring performance in Drupal 8 - DrupalCamp London
A new tool for measuring performance in Drupal 8 - DrupalCamp London
 
OpenERP Technical Memento V0.7.3
OpenERP Technical Memento V0.7.3OpenERP Technical Memento V0.7.3
OpenERP Technical Memento V0.7.3
 
OpenERP Technical Memento
OpenERP Technical MementoOpenERP Technical Memento
OpenERP Technical Memento
 
13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS 13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS
 
AtoZ about TYPO3 v8 CMS
AtoZ about TYPO3 v8 CMSAtoZ about TYPO3 v8 CMS
AtoZ about TYPO3 v8 CMS
 
PHP Frameworks and CodeIgniter
PHP Frameworks and CodeIgniterPHP Frameworks and CodeIgniter
PHP Frameworks and CodeIgniter
 
os-php-wiki5-a4
os-php-wiki5-a4os-php-wiki5-a4
os-php-wiki5-a4
 
os-php-wiki5-a4
os-php-wiki5-a4os-php-wiki5-a4
os-php-wiki5-a4
 
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
 
Drupal Meetup Lisbon
Drupal Meetup LisbonDrupal Meetup Lisbon
Drupal Meetup Lisbon
 
The power of mysqlnd plugins
The power of mysqlnd pluginsThe power of mysqlnd plugins
The power of mysqlnd plugins
 
Symfony2 Introduction Presentation
Symfony2 Introduction PresentationSymfony2 Introduction Presentation
Symfony2 Introduction Presentation
 
Артем Сыльчук - Хранение полей в Drupal. От CCK к FieldableEntityStorageContr...
Артем Сыльчук - Хранение полей в Drupal. От CCK к FieldableEntityStorageContr...Артем Сыльчук - Хранение полей в Drupal. От CCK к FieldableEntityStorageContr...
Артем Сыльчук - Хранение полей в Drupal. От CCK к FieldableEntityStorageContr...
 

Recently uploaded

why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....ShaimaaMohamedGalal
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 

Recently uploaded (20)

why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 

Intro to drupal_7_architecture

  • 1. An Introduction to Drupal Architecture JohnVanDyk DrupalCamp Des Moines, Iowa September 17, 2011 1
  • 2. Apache IIS OS Nginx PHP 5.2.5 Stack with OS, webserver and PHP. Most people use mod_php but deployments with engineers at the helm sometimes use FastCGI. PHP 5.2.4 with the 5.2.5 security backport is fine too (Ubuntu 8.0.4). 2
  • 3. Apache IIS OS Nginx hash date SimpleXMLjson dom SPLpcre filter xmlsession gd pdo pdo_mysql PHP Some PHP extensions are required. 3
  • 6. Apache IIS OS Nginx PHP 5.2.5 MySQL 5.0.15 MariaDB 5.1.44 Drupal 7 Varnish Varnish can be added to the front end for fast RAM-based response to anonymous users. 6
  • 7. Apache Load Balancer PHP 5.2.5 MySQL Drupal 7 OS OS Apache PHP 5.2.5 Drupal 7 OS Apache PHP 5.2.5 Drupal 7 OS Apache PHP 5.2.5 Drupal 7 OS Apache PHP 5.2.5 Drupal 7 OS Apache PHP 5.2.5 Drupal 7 OS Apache PHP 5.2.5 Drupal 7 OS Apache PHP 5.2.5 Drupal 7 OS Apache PHP 5.2.5 Drupal 7 OS Apache PHP 5.2.5 Drupal 7 OS Apache PHP Drupal 7 OS Webheads can be scaled out. 7
  • 8. Apache Load Balancer PHP 5.2.5 MySQL Master Drupal 7 OS OS Apache PHP 5.2.5 Drupal 7 OS Apache PHP 5.2.5 Drupal 7 OS Apache PHP 5.2.5 Drupal 7 OS Apache PHP 5.2.5 Drupal 7 OS Apache PHP 5.2.5 Drupal 7 OS Apache PHP 5.2.5 Drupal 7 OS Apache PHP 5.2.5 Drupal 7 OS Apache PHP 5.2.5 Drupal 7 OS Apache PHP 5.2.5 Drupal 7 OS Apache PHP Drupal 7 OS MySQL Slaves OS MySQL Slaves OS MySQL Slaves OS MySQL Slaves OS Databases can be scaled out. Show master-slave but master- master is also a possibility. See http://www.jochus.be/site/ 2011-01-13/drupal/drupal-master-master-replication-architecture for an example. 8
  • 9. Source: Nate Haug, Lullabot Scaling the Grammys. DrupalCamp Denver 2010. 214 million hits in six hours at peak. Database load: 5%. Apache load: 1%. 9
  • 10. You will not hack core. You should only modify the locations shown in green. Modifying the other files will inevitably lead to grief. 10
  • 11. Development Site Local settings, including database connection info, are in sites/all/ dev.local. 11
  • 12. Live Site On the live site settings are in a site-specific directory. 12
  • 13. http://www.doodlepress.co.uk/item/1460 Drupal 7 Architecture Drupal architecture. Each include file has a different color and their interrelationships are shown. Uh...just kidding. 13
  • 14. Browser request: GET /node/1 Bootstrap (includes/bootstrap.inc) - brings session, database, variables online Menu System (router) - maps URL to a function - checks access control - may bring functions into scope - calls function to build page data structure - calls function to theme page (look and feel) - page returned to client It is important for a developer to understand the sequence of events that occur when a request is processed by Drupal. 14
  • 15. /index.php?q=node/1 /node/1 mod_rewrite in .htaccess $_GET['q'] will contain 'node/1' A typical request starts with mod_rewrite. 15
  • 16. index.php menu system Which function should this path be mapped to? $items['node/%node'] = array( 'page callback' => 'node_page_view', 'page arguments' => array(1), 'access callback' => 'node_access', 'access arguments' => array('view', 1), ); index.php invokes the menu system, which handles much more than menus. The menu item that maps to node/1 can be found in node.module. 16
  • 17. index.php menu system Does this user have permission to access this path? $items['node/%node'] = array( 'page callback' => 'node_page_view', 'page arguments' => array(1), 'access callback' => 'node_access', 'access arguments' => array('view', 1), ); node.module tells the menu system to invoke a function (node_access()) to determine whether the current user has permission. 17
  • 18. index.php menu system node.module /** * Menu callback; view a single node. */ function node_page_view($node) { ... } The page callback for the path node/1 is 'node_page_view'. That's the name of the function that is called if the user has permission to view the page. 18
  • 19. index.php menu system node.module hook_node_load() book.module comment.module forum.module user.module book_node_load() comment_node_load() forum_node_load() user_node_load() Other modules have a say in the loading of the node object. Many of these hooks (better thought of as "events") happen during the building of a page. 19
  • 20. index.php menu system A large array with the node's data structure is returned to the menu system. 20
  • 21. index.php menu system node.module hook_node_view_alter() drupalcorn.module drupalcorn_node_view_alter() Other modules may alter the final data structure. We've seen three common patterns that pervade Drupal: (1) hooks allow other modules to respond to events; (2) Drupal uses large structured arrays, and (3) other modules may alter these arrays once built. 21
  • 22. index.php menu system delivery callback drupal_render_page() theme() page.tpl.php node.tpl.php block.tpl.php The menu system passes the structure array to a delivery callback which turns the array into HTML by rendering it; that is, passing it through Drupal's template engine. Template files (.tpl.php, pronounced "tipple-fipp") in the current theme are used to create the HTML. 22
  • 23. index.php The HTML is then returned to the browser. 23
  • 24. Common Library Database API Fields API Entity API N o d e s U s e r s T a x o n o m y C o m m e n t s Form API Menu API Block API Locali zation Views Template Preprocessing Theme Modules add functionality here Block diagram if you need a mental model. This doesnʼt have nearly enough dimensions to describe what actually happens. If you asked 5 developers to make Drupal block diagrams, you'd get 5 different diagrams. Hopefully this one helps someone. 24
  • 25. "Entities" Node: a piece of content User: a user account Taxonomy: categories for tagging/classification Comment: content with a parent 25
  • 26. An Entity has Bundles Node Title Body Title Body Page An entity can be thought of as a base object, and bundles are subclasses. For example, a node is an entity while the bundle of fields that make up a page are a type of node. 26
  • 27. An Entity has Bundles Title Body Page Title Body Article Tags Image These are types of nodes. Each has a bundle of fields. 27
  • 28. A Bundle has Fields Title Body Article Tags Image text_long text_with_summary taxonomy_term_reference image And each field has a type. 28
  • 29. Not SQL Fields Title Body Article Tags Image text_with_summary taxonomy_term_reference These are more than SQL fields. text_with_summary autogenerates a summary. taxonomy_term_reference splits multiple tags into separate records. These are Drupal fields. 29
  • 30. In the Real World "Entity" = node | user | comment | taxonomy "Bundle" = "Content Type" You assemble content types from fields using the UI. Part of the conversation with your client! Nobody says "let's create a new Node Bundle and call it Bug Report". 30
  • 31. Before Building a Site • What content types and fields? • How will the data get in? (Forms) • How will the data get out? (Views) • Who may create/view/delete data? (Permissions) • What additional functionality? (Modules) • How can we make it pretty? (Theming) Questions to map client needs to Drupal concepts. 31
  • 32. http://api.drupal.org Your home for API-related searches. 32
  • 33. http://drupal.org/project/examples Simple implementations of APIs. You can base your own work on these examples. 33
  • 34. Bonus! Two tools I use all the time. 34
  • 35. Defeating the White Screen of Death error_log = /var/log/php/error.log Define PHP error log in php.ini: I close with two essential tools. First, don't be frightened by the WSOD. 35
  • 36. tail -f /var/log/php/error.log [07-Sep-2011 16:25:02] PHP Fatal error: Call to undefined function int() in bgstat.module on line 41 Watch the error log to find out what’s going on: PHP will always tell you what went wrong in its log. If you've defined a PHP error log in php.ini, you can watch it in real time with tail -f. 36
  • 37. Where is the code? egrep -rn searchstring . Quickly search the codebase for a function: Second, don't be overwhelmed with the codebase. egrep and pipes can help you find where functions live and where things happen. Example: where are mail-related variables set? 37
  • 38. egrep -rn mail . | grep variable_set ./includes/install.core.inc:1802: variable_set('site_mail', $form_state['values'] ['site_mail']); ./includes/install.core.inc:1813: variable_set('update_notify_emails', array($form_state ['values']['account']['mail'])); ./modules/openid/openid.test:323: variable_set('user_email_verification',TRUE); ... There we go. The codebase is like a rich porridge, waiting for you to sift through and find the tasty lumps. 38
  • 39. Thanks! Hopefully these help create a big picture of how Drupal works.This only scratches the surface. Now get your debugger working and explore Drupal core on your own! 39