SlideShare a Scribd company logo
1 of 57
Becoming A Drupal
Master Builder
Philip Norton
Blog at #! code (www.hashbangcode.com)
@philipnorton42 on Twitter
Technical Lead at
Philip Norton
Creator of Vlad Helps run NWDUG
==
https://www.flickr.com/photos/chrish_99/6730952349/
http://buytaert.net/album/birthday-axl-2011/dries-with-lego
My Experience
● 10+ years in programming
● 8+ years in the web industry
● 6+ years building Drupal sites
● 4+ years as Technical Lead at Access
● Development, system design, database and server
administration, consulting, SEO, usability, training,
mentoring
Other People’s Projects
● Reviewing projects built internally
● Migrating existing Drupal sites
● Third party sites that we need to host and maintain
● Rescue jobs
The good thing about
PHP, is it’s really easy
to learn.
The bad thing about
PHP, is it’s really easy
to learn
Ben Dechrai
Contents
● Drupal File Architecture
● Coding
● Configuration
● Contrib Modules
Drupal File Architecture
Drupal File Structure
● Custom/contrib for the modules directory
-- sites
---- all
------ modules
-------- contrib
-------- custom
● Easy to spot what the custom modules are
● Makes analysing custom code much easier
● Always use sites/default/files to store your
files, it will make life easier in the long run
Multi-site Setups
● Use DNS entries to auto-detect your file directory
sites/www.example.com/files
sites/www.example.com/modules
sites/www.example.com/settings.php
● Nice idea
● In practice it causes more problems than it solves
● This is used even when not needed
Themes
● Use the template.php file for theme overrides and
helper functions
● Do not use the template.php file to run database
commands
● Do not hardcode ID’s all over the place
● Use generic templates and stop template proliferation
● Drupal 8 forces you to stop using logic in your
templates and instead use preprocess hooks
Overly Specifying Specific Specifics
● More specific custom code means more stuff to break
if ($node->nid == 1234) {
}
● Node ID and Block ID specific templates
● Use of taxonomy term ID to control things
● If you have to use specifics then use configuration to
set these values
Drupal Module File Structure
● Lots of Drupal 7 hooks come with a file parameter
● Use it to move functionality into different files
● Namespace your module functions in Drupal 7
my_custom_module_some_function()
● Put all classes in their own files
● Use the X Autoload module to use PSR-4 in Drupal 7
● Drupal 8 Forces PSR-4! :)
http://www.jpstacey.info/blog/2015-06-22/architecting-drupal-7-module-multiple-files
Drupal Module Documentation
● Add documentation to your modules
● Write more than the basics in your info file
name = Tool Tips module
description = A module for tool tips
● Add a readme file and detail to the drupal.org module
page
● Also think about adding install and configure help
Drupal CHANGELOG.txt
● Don’t allow information leakage by including the
CHANGELOG.txt file in your Drupal install
● Restrict access via webserver configs
● Can also remove them from your codebase but the
Hacked! module will complain
● Alternatively, simply remove them as part of your
deployment process
Drupal Custom Code
● Don’t reinvent the wheel, use Drupal’s framework
● Use third party modules to provide functionality as
much as possible
● Use Drupal’s hooks to accomplish actions or change
existing functionality
Coding
Don’t Hack Core
● There are a million good reasons not to do this
● This includes contributed module and theme hacks
● Patching is ok as a last resort, BUT document your
changes!
● Do it the right way, learn about hooks, overrides and
child themes
https://www.drupal.org/best-practices/do-not-hack-core
Version Control
● Use version control
● Seriously, use it
● Git is good, so is Mercurial
● Commit often, use commit messages, describe your
changes
Version Control Branches
● Git branching is cheap
● Use git flow (or a variant)
● The master branch is a copy of the live site
● All work should be done on a development branch and
merged with master when ready for deployment
Version Control Etiquette
● Describe your work in commit messages
● Don’t add databases to your git repo
● Don’t include the user files directory in your git repo!
● settings.php file is debatable, just be careful of
adding usernames and passwords to your repos
● Use a local settings file
if (file_exists(__DIR__ . '/settings.local.php')) {
include __DIR__ . '/settings.local.php';
}
Use An IDE
● Syntax highlighting, code navigation, debugging,
autocomplete, auto formatting and more!
● Quickly spot unused variables
● Detect errors and problems before you commit the
code
Development Environment
● Try to replicate your production environment when
developing
● Stop silly errors creeping into the live site
● WAMP/MAMP solutions just don’t cut it
● Use Vagrant and a provisioning tool
● Vlad! :)
PHP Errors
● Syntax errors should never make it into production
● PHP Notices and Warnings are also NOT acceptable
in a production environment!
● Understand the internal Drupal error processing
(See _drupal_log_error() in Drupal 7)
● Don’t use @ to suppress warnings, it’s lazy and has
performance implications
● Use try {...} catch() {...} block to catch
exceptions
Coding Standards
● Pick a coding standard and stick to it
● Use the Code Sniffer tool, preferably with the Drupal
coding standards files
● Implement a continuous integration system to auto
check the code (e.g. Jenkins)
● Coder module (https://www.drupal.org/project/coder)
has everything you need
https://www.drupal.org/coding-standards
Cyclomatic Complexity
● The total number of paths of execution through a block
of code
if ($variable == TRUE) {
do_something();
}
else {
do_something_else();
}
● High numbers are bad (harder to read and maintain)
● Use PHPMD to inspect your own code and refactor
complexity
Cyclomatic Complexity = 2
Always code as if the
person who ends up
maintaining your code
is a violent psychopath
who knows where you
live.
John Woods
Drupal Tests
● Drupal has a test module bundled
● Drupal 7 uses Simpletest, Drupal 8 uses Simpletest
and PHPUnit
● Write tests!
● Test current functionality, re-run tests when refactoring
or adding new functionality
● Can take time to write tests, but it’s worth it in the long
run
Configuration
Drupal Content Types
● Content type != template type
Press Release
News Article
Front Page News Article
● A mistake that many site builders make
● Create functional content types, use data to control
them
CSS/JavaScript Aggregation
● Turn it on!
● Reduce the size of your files and the number of files
downloaded
● Reduces server load and decreases page load speed
● Try it before you deploy live, some CSS/JavaScript
code can be broken by this
● Spot problems before they appear in live
environments
Fieldsets And Vertical Tabs
● 40+ fields on your content types makes a long edit
page
● Use vertical tabs and fieldsets to break the page up
● Field Group module has this functionality
● Try to avoid using “Unlimited” cardinality on fields
especially on file fields
● Think about how your users will edit pages
Permissions
● General rule is to restrict user permissions to the core
activities they will be doing
● Giving users too much access can be confusing,
especially for new Drupal users
● Also don’t allow lots of ‘superuser’ roles as it becomes
difficult to restrict access
PHP Filter
● The PHP Filter module is bad, never use it
● Execution of PHP is slow and uncachable
● Quickly creates an unmaintainable mess
● Lots of security implications
● Removed from Drupal 8 (with much fanfare!)
Running Cron
● Don't get your users to run cron, put it in crontab
● Use the Elysia Cron module to process cron tasks at
different times
● Can see a massive (90%+) reduction in the cron
footprint
https://www.drupal.org/project/elysia_cron
Updates
● Some modules use update hooks to run actions,
usually to add or update database tables
● It is essential that you run update.php when you
deploy an update to a module
● Using ‘drush updatedb’ also works well here
Uninstall Deactivated Modules
● Uninstalling modules is important as they leave behind
tables and data that isn’t used
● Turn off and uninstall modules before deleting them
Contrib Modules
Views, Views, Views
● Use Views to show lists of content
● Built into Drupal 8
● Don’t duplicate a View to display the same thing on
different pages
● Use contextual filters to alter the same View in
different contexts
● Remember to add pagination and limits
Pathauto
● Seeing node/123 on production websites makes me
cringe
● Use Pathauto to create pretty paths from node data
● Creates SEO friendly paths
https://www.drupal.org/project/pathauto
Context
● React to certain page level conditions
- Paths
- Views
- Content Types
- Menu Items
- Taxonomy Terms
● Much better and more controlled block placement in
Drupal 7
● Fully exportable so placement can be kept in config
https://www.drupal.org/project/context
Advanced Aggregation
● Compress your CSS and JS even more
● GZips your code for smaller size when transporting
https://www.drupal.org/project/advagg
UI Modules
● Many modules come with a user interface (UI) sub
module that wrap the administration interface
- Views UI
- Context UI
- Rules UI
- Display Suite UI
etc...
● Turn them off in production
Devel
● Really powerful module
● Makes development easy in Drupal
● Awesome sub modules like Devel Generate and Devel
Node Access
● Who doesn’t love Devel?
● Don’t, don’t, DON’T leave it running it production!
● Also, DON’T commit dpm() into your code!
Stage File Proxy
● Really good module for using uploaded files on a dev
platform without having to download the user files
directory from production
● No need deploy to production
https://www.drupal.org/project/stage_file_proxy
Features
● Features allows modules to be made that create
Content Types, Fields, Views, Contexts, Rules, and
many more types of configuration
● Allows you to see when things have changed and
allows easy deployment of new functionality
● Try to add as much configuration into code as possible
● Group like items together
https://www.drupal.org/project/features
Spotting Problems
opensource.com
● JavaScript aggregation is
turned off (but not CSS?)
● Messy module directory
structure (due to Panopoly
distribution)
Cisco Internet Of Everything
● Runs Drupal 7.24 (as seen
from CHANGELOG.txt)
● Vulnerable to SA-CORE-
2014-005?
belgium.be
● Lots of stuff done right
● CSS and JavaScript
aggregation turned off
Greater Than Games
● Runs Drupal 7.41, as seen in
CHANGELOG.txt
● Multi-site setup
Elite Dangerous Community Site
● CSS/JavaScript aggregation
is turned off
● Some use of Path Auto so
URL’s like ‘node/123’ are
common
● Multi-site setup
● Hacked the Bootstrap theme
to make a sub-theme
● Call me! :)
Top Tips
Some things to take away with you
Top Tips
● Have a go live plan
● Think about the experience of all of your users
● Don’t overcomplicate simple functionality
● Don’t use specific templates, generalise
● Think about the long term life of the site
● Learn the system (i.e. Drupal)
Becoming A Drupal Master Builder

More Related Content

What's hot

Drupal 8 - Corso frontend development
Drupal 8 - Corso frontend developmentDrupal 8 - Corso frontend development
Drupal 8 - Corso frontend developmentsparkfabrik
 
Django Architecture Introduction
Django Architecture IntroductionDjango Architecture Introduction
Django Architecture IntroductionHaiqi Chen
 
Configuration Management in Drupal 8: A preview (DrupalCamp Alpe Adria 2014)
Configuration Management in Drupal 8: A preview (DrupalCamp Alpe Adria 2014)Configuration Management in Drupal 8: A preview (DrupalCamp Alpe Adria 2014)
Configuration Management in Drupal 8: A preview (DrupalCamp Alpe Adria 2014)Nuvole
 
Drupal Javascript for developers
Drupal Javascript for developersDrupal Javascript for developers
Drupal Javascript for developersDream Production AG
 
Building a Dynamic Website Using Django
Building a Dynamic Website Using DjangoBuilding a Dynamic Website Using Django
Building a Dynamic Website Using DjangoNathan Eror
 
Making Magento flying like a rocket! (A set of valuable tips for developers)
Making Magento flying like a rocket! (A set of valuable tips for developers)Making Magento flying like a rocket! (A set of valuable tips for developers)
Making Magento flying like a rocket! (A set of valuable tips for developers)Ivan Chepurnyi
 
Migrate yourself. code -> module -> mind
Migrate yourself. code -> module -> mindMigrate yourself. code -> module -> mind
Migrate yourself. code -> module -> mindValentine Matsveiko
 
Convert modules from 6.x to 7.x
Convert modules from 6.x to 7.xConvert modules from 6.x to 7.x
Convert modules from 6.x to 7.xJoão Ventura
 
jQuery and_drupal
jQuery and_drupaljQuery and_drupal
jQuery and_drupalBlackCatWeb
 
Multi Tenancy With Python and Django
Multi Tenancy With Python and DjangoMulti Tenancy With Python and Django
Multi Tenancy With Python and Djangoscottcrespo
 
Phase2 OpenPublish Presentation SF SemWeb Meetup, April 28, 2009
Phase2 OpenPublish Presentation SF SemWeb Meetup, April 28, 2009Phase2 OpenPublish Presentation SF SemWeb Meetup, April 28, 2009
Phase2 OpenPublish Presentation SF SemWeb Meetup, April 28, 2009Krista Thomas
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)arcware
 
SaaSy maps - using django-tenants and geodjango to provide web-gis software-a...
SaaSy maps - using django-tenants and geodjango to provide web-gis software-a...SaaSy maps - using django-tenants and geodjango to provide web-gis software-a...
SaaSy maps - using django-tenants and geodjango to provide web-gis software-a...Anusha Chickermane
 
Drupal 8 deploying
Drupal 8 deployingDrupal 8 deploying
Drupal 8 deployingAndrew Siz
 
Web applications with Catalyst
Web applications with CatalystWeb applications with Catalyst
Web applications with Catalystsvilen.ivanov
 
Render API - Pavel Makhrinsky
Render API - Pavel MakhrinskyRender API - Pavel Makhrinsky
Render API - Pavel MakhrinskyDrupalCampDN
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2fishwarter
 
Drupal 8 CMI on a Managed Workflow
Drupal 8 CMI on a Managed WorkflowDrupal 8 CMI on a Managed Workflow
Drupal 8 CMI on a Managed WorkflowPantheon
 

What's hot (20)

Drupal 8 - Corso frontend development
Drupal 8 - Corso frontend developmentDrupal 8 - Corso frontend development
Drupal 8 - Corso frontend development
 
Django Architecture Introduction
Django Architecture IntroductionDjango Architecture Introduction
Django Architecture Introduction
 
Configuration Management in Drupal 8: A preview (DrupalCamp Alpe Adria 2014)
Configuration Management in Drupal 8: A preview (DrupalCamp Alpe Adria 2014)Configuration Management in Drupal 8: A preview (DrupalCamp Alpe Adria 2014)
Configuration Management in Drupal 8: A preview (DrupalCamp Alpe Adria 2014)
 
Drupal Javascript for developers
Drupal Javascript for developersDrupal Javascript for developers
Drupal Javascript for developers
 
Building a Dynamic Website Using Django
Building a Dynamic Website Using DjangoBuilding a Dynamic Website Using Django
Building a Dynamic Website Using Django
 
Making Magento flying like a rocket! (A set of valuable tips for developers)
Making Magento flying like a rocket! (A set of valuable tips for developers)Making Magento flying like a rocket! (A set of valuable tips for developers)
Making Magento flying like a rocket! (A set of valuable tips for developers)
 
Migrate yourself. code -> module -> mind
Migrate yourself. code -> module -> mindMigrate yourself. code -> module -> mind
Migrate yourself. code -> module -> mind
 
Convert modules from 6.x to 7.x
Convert modules from 6.x to 7.xConvert modules from 6.x to 7.x
Convert modules from 6.x to 7.x
 
jQuery and_drupal
jQuery and_drupaljQuery and_drupal
jQuery and_drupal
 
Multi Tenancy With Python and Django
Multi Tenancy With Python and DjangoMulti Tenancy With Python and Django
Multi Tenancy With Python and Django
 
Phase2 OpenPublish Presentation SF SemWeb Meetup, April 28, 2009
Phase2 OpenPublish Presentation SF SemWeb Meetup, April 28, 2009Phase2 OpenPublish Presentation SF SemWeb Meetup, April 28, 2009
Phase2 OpenPublish Presentation SF SemWeb Meetup, April 28, 2009
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
 
SaaSy maps - using django-tenants and geodjango to provide web-gis software-a...
SaaSy maps - using django-tenants and geodjango to provide web-gis software-a...SaaSy maps - using django-tenants and geodjango to provide web-gis software-a...
SaaSy maps - using django-tenants and geodjango to provide web-gis software-a...
 
Drupal 8 deploying
Drupal 8 deployingDrupal 8 deploying
Drupal 8 deploying
 
Django
DjangoDjango
Django
 
Web applications with Catalyst
Web applications with CatalystWeb applications with Catalyst
Web applications with Catalyst
 
Render API - Pavel Makhrinsky
Render API - Pavel MakhrinskyRender API - Pavel Makhrinsky
Render API - Pavel Makhrinsky
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2
 
Zend framework
Zend frameworkZend framework
Zend framework
 
Drupal 8 CMI on a Managed Workflow
Drupal 8 CMI on a Managed WorkflowDrupal 8 CMI on a Managed Workflow
Drupal 8 CMI on a Managed Workflow
 

Similar to Becoming A Drupal Master Builder

Help! I inherited a Drupal Site! - DrupalCamp Atlanta 2016
Help! I inherited a Drupal Site! - DrupalCamp Atlanta 2016Help! I inherited a Drupal Site! - DrupalCamp Atlanta 2016
Help! I inherited a Drupal Site! - DrupalCamp Atlanta 2016Paul McKibben
 
Drupal in 5mins + Previewing Drupal 8.x
Drupal in 5mins + Previewing Drupal 8.xDrupal in 5mins + Previewing Drupal 8.x
Drupal in 5mins + Previewing Drupal 8.xWong Hoi Sing Edison
 
Drupal + composer = new love !?
Drupal + composer = new love !?Drupal + composer = new love !?
Drupal + composer = new love !?nuppla
 
Choosing Drupal as your Content Management Framework
Choosing Drupal as your Content Management FrameworkChoosing Drupal as your Content Management Framework
Choosing Drupal as your Content Management FrameworkMediacurrent
 
Modernize Your Drupal Development
Modernize Your Drupal DevelopmentModernize Your Drupal Development
Modernize Your Drupal DevelopmentChris Tankersley
 
Hong Kong Drupal User Group - 2014 March 8th
Hong Kong Drupal User Group - 2014 March 8thHong Kong Drupal User Group - 2014 March 8th
Hong Kong Drupal User Group - 2014 March 8thWong Hoi Sing Edison
 
Drupal 8 improvements for developer productivity php symfony and more
Drupal 8 improvements for developer productivity  php symfony and moreDrupal 8 improvements for developer productivity  php symfony and more
Drupal 8 improvements for developer productivity php symfony and moreAcquia
 
Moodle Development Best Pracitces
Moodle Development Best PracitcesMoodle Development Best Pracitces
Moodle Development Best PracitcesJustin Filip
 
Drupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesDrupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesShabir Ahmad
 
Drupal Architecture and functionality
Drupal Architecture and functionality Drupal Architecture and functionality
Drupal Architecture and functionality Ann Lam
 
Open Innovation Lab (OIL) - 2014 Sep 26th
Open Innovation Lab (OIL) - 2014 Sep 26thOpen Innovation Lab (OIL) - 2014 Sep 26th
Open Innovation Lab (OIL) - 2014 Sep 26thWong Hoi Sing Edison
 
[HKDUG] #20180512 - Fix Hacked Drupal with GIT
[HKDUG] #20180512 - Fix Hacked Drupal with GIT[HKDUG] #20180512 - Fix Hacked Drupal with GIT
[HKDUG] #20180512 - Fix Hacked Drupal with GITWong Hoi Sing Edison
 
Top 20 mistakes you will make on your 1st Drupal project
Top 20 mistakes you will make on your 1st Drupal projectTop 20 mistakes you will make on your 1st Drupal project
Top 20 mistakes you will make on your 1st Drupal projectIztok Smolic
 
Decoupling Drupal mit dem Lupus Nuxt.js Drupal Stack
Decoupling Drupal mit dem Lupus Nuxt.js Drupal StackDecoupling Drupal mit dem Lupus Nuxt.js Drupal Stack
Decoupling Drupal mit dem Lupus Nuxt.js Drupal Stacknuppla
 
Drupal training-1-in-mumbai
Drupal training-1-in-mumbaiDrupal training-1-in-mumbai
Drupal training-1-in-mumbaivibrantuser
 
Efficient development workflows with composer
Efficient development workflows with composerEfficient development workflows with composer
Efficient development workflows with composernuppla
 
Implementing a Symfony Based CMS in a Publishing Company
Implementing a Symfony Based CMS in a Publishing CompanyImplementing a Symfony Based CMS in a Publishing Company
Implementing a Symfony Based CMS in a Publishing CompanyMarcos Labad
 
Drupal and contribution (2010 - 2011 / 2)
Drupal and contribution (2010 - 2011 / 2)Drupal and contribution (2010 - 2011 / 2)
Drupal and contribution (2010 - 2011 / 2)Peter Arato
 

Similar to Becoming A Drupal Master Builder (20)

Help! I inherited a Drupal Site! - DrupalCamp Atlanta 2016
Help! I inherited a Drupal Site! - DrupalCamp Atlanta 2016Help! I inherited a Drupal Site! - DrupalCamp Atlanta 2016
Help! I inherited a Drupal Site! - DrupalCamp Atlanta 2016
 
Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practices
 
Drupal in 5mins + Previewing Drupal 8.x
Drupal in 5mins + Previewing Drupal 8.xDrupal in 5mins + Previewing Drupal 8.x
Drupal in 5mins + Previewing Drupal 8.x
 
Drupal + composer = new love !?
Drupal + composer = new love !?Drupal + composer = new love !?
Drupal + composer = new love !?
 
Choosing Drupal as your Content Management Framework
Choosing Drupal as your Content Management FrameworkChoosing Drupal as your Content Management Framework
Choosing Drupal as your Content Management Framework
 
Modernize Your Drupal Development
Modernize Your Drupal DevelopmentModernize Your Drupal Development
Modernize Your Drupal Development
 
Hong Kong Drupal User Group - 2014 March 8th
Hong Kong Drupal User Group - 2014 March 8thHong Kong Drupal User Group - 2014 March 8th
Hong Kong Drupal User Group - 2014 March 8th
 
Drupal 8 improvements for developer productivity php symfony and more
Drupal 8 improvements for developer productivity  php symfony and moreDrupal 8 improvements for developer productivity  php symfony and more
Drupal 8 improvements for developer productivity php symfony and more
 
Moodle Development Best Pracitces
Moodle Development Best PracitcesMoodle Development Best Pracitces
Moodle Development Best Pracitces
 
Drupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesDrupal 8 - Core and API Changes
Drupal 8 - Core and API Changes
 
Drupal Architecture and functionality
Drupal Architecture and functionality Drupal Architecture and functionality
Drupal Architecture and functionality
 
Drupal in-depth
Drupal in-depthDrupal in-depth
Drupal in-depth
 
Open Innovation Lab (OIL) - 2014 Sep 26th
Open Innovation Lab (OIL) - 2014 Sep 26thOpen Innovation Lab (OIL) - 2014 Sep 26th
Open Innovation Lab (OIL) - 2014 Sep 26th
 
[HKDUG] #20180512 - Fix Hacked Drupal with GIT
[HKDUG] #20180512 - Fix Hacked Drupal with GIT[HKDUG] #20180512 - Fix Hacked Drupal with GIT
[HKDUG] #20180512 - Fix Hacked Drupal with GIT
 
Top 20 mistakes you will make on your 1st Drupal project
Top 20 mistakes you will make on your 1st Drupal projectTop 20 mistakes you will make on your 1st Drupal project
Top 20 mistakes you will make on your 1st Drupal project
 
Decoupling Drupal mit dem Lupus Nuxt.js Drupal Stack
Decoupling Drupal mit dem Lupus Nuxt.js Drupal StackDecoupling Drupal mit dem Lupus Nuxt.js Drupal Stack
Decoupling Drupal mit dem Lupus Nuxt.js Drupal Stack
 
Drupal training-1-in-mumbai
Drupal training-1-in-mumbaiDrupal training-1-in-mumbai
Drupal training-1-in-mumbai
 
Efficient development workflows with composer
Efficient development workflows with composerEfficient development workflows with composer
Efficient development workflows with composer
 
Implementing a Symfony Based CMS in a Publishing Company
Implementing a Symfony Based CMS in a Publishing CompanyImplementing a Symfony Based CMS in a Publishing Company
Implementing a Symfony Based CMS in a Publishing Company
 
Drupal and contribution (2010 - 2011 / 2)
Drupal and contribution (2010 - 2011 / 2)Drupal and contribution (2010 - 2011 / 2)
Drupal and contribution (2010 - 2011 / 2)
 

More from Philip Norton

Webform and Drupal 8
Webform and Drupal 8Webform and Drupal 8
Webform and Drupal 8Philip Norton
 
Acquia Drupal Certification
Acquia Drupal CertificationAcquia Drupal Certification
Acquia Drupal CertificationPhilip Norton
 
Drupal Performance : DrupalCamp North
Drupal Performance : DrupalCamp NorthDrupal Performance : DrupalCamp North
Drupal Performance : DrupalCamp NorthPhilip Norton
 
Getting Started With Jenkins And Drupal
Getting Started With Jenkins And DrupalGetting Started With Jenkins And Drupal
Getting Started With Jenkins And DrupalPhilip Norton
 
Making The Drupal Pill Easier To Swallow
Making The Drupal Pill Easier To SwallowMaking The Drupal Pill Easier To Swallow
Making The Drupal Pill Easier To SwallowPhilip Norton
 

More from Philip Norton (9)

ReactPHP
ReactPHPReactPHP
ReactPHP
 
Webform and Drupal 8
Webform and Drupal 8Webform and Drupal 8
Webform and Drupal 8
 
Acquia Drupal Certification
Acquia Drupal CertificationAcquia Drupal Certification
Acquia Drupal Certification
 
Drupal Performance : DrupalCamp North
Drupal Performance : DrupalCamp NorthDrupal Performance : DrupalCamp North
Drupal Performance : DrupalCamp North
 
Getting Started With Jenkins And Drupal
Getting Started With Jenkins And DrupalGetting Started With Jenkins And Drupal
Getting Started With Jenkins And Drupal
 
Drupal theming
Drupal themingDrupal theming
Drupal theming
 
Drush
DrushDrush
Drush
 
Making The Drupal Pill Easier To Swallow
Making The Drupal Pill Easier To SwallowMaking The Drupal Pill Easier To Swallow
Making The Drupal Pill Easier To Swallow
 
Drupal 7 Queues
Drupal 7 QueuesDrupal 7 Queues
Drupal 7 Queues
 

Recently uploaded

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 

Recently uploaded (20)

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 

Becoming A Drupal Master Builder

  • 1. Becoming A Drupal Master Builder Philip Norton
  • 2. Blog at #! code (www.hashbangcode.com) @philipnorton42 on Twitter Technical Lead at Philip Norton Creator of Vlad Helps run NWDUG
  • 3. ==
  • 6. My Experience ● 10+ years in programming ● 8+ years in the web industry ● 6+ years building Drupal sites ● 4+ years as Technical Lead at Access ● Development, system design, database and server administration, consulting, SEO, usability, training, mentoring
  • 7. Other People’s Projects ● Reviewing projects built internally ● Migrating existing Drupal sites ● Third party sites that we need to host and maintain ● Rescue jobs
  • 8. The good thing about PHP, is it’s really easy to learn. The bad thing about PHP, is it’s really easy to learn Ben Dechrai
  • 9. Contents ● Drupal File Architecture ● Coding ● Configuration ● Contrib Modules
  • 11. Drupal File Structure ● Custom/contrib for the modules directory -- sites ---- all ------ modules -------- contrib -------- custom ● Easy to spot what the custom modules are ● Makes analysing custom code much easier ● Always use sites/default/files to store your files, it will make life easier in the long run
  • 12. Multi-site Setups ● Use DNS entries to auto-detect your file directory sites/www.example.com/files sites/www.example.com/modules sites/www.example.com/settings.php ● Nice idea ● In practice it causes more problems than it solves ● This is used even when not needed
  • 13. Themes ● Use the template.php file for theme overrides and helper functions ● Do not use the template.php file to run database commands ● Do not hardcode ID’s all over the place ● Use generic templates and stop template proliferation ● Drupal 8 forces you to stop using logic in your templates and instead use preprocess hooks
  • 14. Overly Specifying Specific Specifics ● More specific custom code means more stuff to break if ($node->nid == 1234) { } ● Node ID and Block ID specific templates ● Use of taxonomy term ID to control things ● If you have to use specifics then use configuration to set these values
  • 15. Drupal Module File Structure ● Lots of Drupal 7 hooks come with a file parameter ● Use it to move functionality into different files ● Namespace your module functions in Drupal 7 my_custom_module_some_function() ● Put all classes in their own files ● Use the X Autoload module to use PSR-4 in Drupal 7 ● Drupal 8 Forces PSR-4! :) http://www.jpstacey.info/blog/2015-06-22/architecting-drupal-7-module-multiple-files
  • 16. Drupal Module Documentation ● Add documentation to your modules ● Write more than the basics in your info file name = Tool Tips module description = A module for tool tips ● Add a readme file and detail to the drupal.org module page ● Also think about adding install and configure help
  • 17. Drupal CHANGELOG.txt ● Don’t allow information leakage by including the CHANGELOG.txt file in your Drupal install ● Restrict access via webserver configs ● Can also remove them from your codebase but the Hacked! module will complain ● Alternatively, simply remove them as part of your deployment process
  • 18. Drupal Custom Code ● Don’t reinvent the wheel, use Drupal’s framework ● Use third party modules to provide functionality as much as possible ● Use Drupal’s hooks to accomplish actions or change existing functionality
  • 20. Don’t Hack Core ● There are a million good reasons not to do this ● This includes contributed module and theme hacks ● Patching is ok as a last resort, BUT document your changes! ● Do it the right way, learn about hooks, overrides and child themes https://www.drupal.org/best-practices/do-not-hack-core
  • 21. Version Control ● Use version control ● Seriously, use it ● Git is good, so is Mercurial ● Commit often, use commit messages, describe your changes
  • 22. Version Control Branches ● Git branching is cheap ● Use git flow (or a variant) ● The master branch is a copy of the live site ● All work should be done on a development branch and merged with master when ready for deployment
  • 23. Version Control Etiquette ● Describe your work in commit messages ● Don’t add databases to your git repo ● Don’t include the user files directory in your git repo! ● settings.php file is debatable, just be careful of adding usernames and passwords to your repos ● Use a local settings file if (file_exists(__DIR__ . '/settings.local.php')) { include __DIR__ . '/settings.local.php'; }
  • 24. Use An IDE ● Syntax highlighting, code navigation, debugging, autocomplete, auto formatting and more! ● Quickly spot unused variables ● Detect errors and problems before you commit the code
  • 25. Development Environment ● Try to replicate your production environment when developing ● Stop silly errors creeping into the live site ● WAMP/MAMP solutions just don’t cut it ● Use Vagrant and a provisioning tool ● Vlad! :)
  • 26. PHP Errors ● Syntax errors should never make it into production ● PHP Notices and Warnings are also NOT acceptable in a production environment! ● Understand the internal Drupal error processing (See _drupal_log_error() in Drupal 7) ● Don’t use @ to suppress warnings, it’s lazy and has performance implications ● Use try {...} catch() {...} block to catch exceptions
  • 27. Coding Standards ● Pick a coding standard and stick to it ● Use the Code Sniffer tool, preferably with the Drupal coding standards files ● Implement a continuous integration system to auto check the code (e.g. Jenkins) ● Coder module (https://www.drupal.org/project/coder) has everything you need https://www.drupal.org/coding-standards
  • 28. Cyclomatic Complexity ● The total number of paths of execution through a block of code if ($variable == TRUE) { do_something(); } else { do_something_else(); } ● High numbers are bad (harder to read and maintain) ● Use PHPMD to inspect your own code and refactor complexity Cyclomatic Complexity = 2
  • 29. Always code as if the person who ends up maintaining your code is a violent psychopath who knows where you live. John Woods
  • 30. Drupal Tests ● Drupal has a test module bundled ● Drupal 7 uses Simpletest, Drupal 8 uses Simpletest and PHPUnit ● Write tests! ● Test current functionality, re-run tests when refactoring or adding new functionality ● Can take time to write tests, but it’s worth it in the long run
  • 32. Drupal Content Types ● Content type != template type Press Release News Article Front Page News Article ● A mistake that many site builders make ● Create functional content types, use data to control them
  • 33. CSS/JavaScript Aggregation ● Turn it on! ● Reduce the size of your files and the number of files downloaded ● Reduces server load and decreases page load speed ● Try it before you deploy live, some CSS/JavaScript code can be broken by this ● Spot problems before they appear in live environments
  • 34. Fieldsets And Vertical Tabs ● 40+ fields on your content types makes a long edit page ● Use vertical tabs and fieldsets to break the page up ● Field Group module has this functionality ● Try to avoid using “Unlimited” cardinality on fields especially on file fields ● Think about how your users will edit pages
  • 35. Permissions ● General rule is to restrict user permissions to the core activities they will be doing ● Giving users too much access can be confusing, especially for new Drupal users ● Also don’t allow lots of ‘superuser’ roles as it becomes difficult to restrict access
  • 36. PHP Filter ● The PHP Filter module is bad, never use it ● Execution of PHP is slow and uncachable ● Quickly creates an unmaintainable mess ● Lots of security implications ● Removed from Drupal 8 (with much fanfare!)
  • 37. Running Cron ● Don't get your users to run cron, put it in crontab ● Use the Elysia Cron module to process cron tasks at different times ● Can see a massive (90%+) reduction in the cron footprint https://www.drupal.org/project/elysia_cron
  • 38. Updates ● Some modules use update hooks to run actions, usually to add or update database tables ● It is essential that you run update.php when you deploy an update to a module ● Using ‘drush updatedb’ also works well here
  • 39. Uninstall Deactivated Modules ● Uninstalling modules is important as they leave behind tables and data that isn’t used ● Turn off and uninstall modules before deleting them
  • 41. Views, Views, Views ● Use Views to show lists of content ● Built into Drupal 8 ● Don’t duplicate a View to display the same thing on different pages ● Use contextual filters to alter the same View in different contexts ● Remember to add pagination and limits
  • 42. Pathauto ● Seeing node/123 on production websites makes me cringe ● Use Pathauto to create pretty paths from node data ● Creates SEO friendly paths https://www.drupal.org/project/pathauto
  • 43. Context ● React to certain page level conditions - Paths - Views - Content Types - Menu Items - Taxonomy Terms ● Much better and more controlled block placement in Drupal 7 ● Fully exportable so placement can be kept in config https://www.drupal.org/project/context
  • 44. Advanced Aggregation ● Compress your CSS and JS even more ● GZips your code for smaller size when transporting https://www.drupal.org/project/advagg
  • 45. UI Modules ● Many modules come with a user interface (UI) sub module that wrap the administration interface - Views UI - Context UI - Rules UI - Display Suite UI etc... ● Turn them off in production
  • 46. Devel ● Really powerful module ● Makes development easy in Drupal ● Awesome sub modules like Devel Generate and Devel Node Access ● Who doesn’t love Devel? ● Don’t, don’t, DON’T leave it running it production! ● Also, DON’T commit dpm() into your code!
  • 47. Stage File Proxy ● Really good module for using uploaded files on a dev platform without having to download the user files directory from production ● No need deploy to production https://www.drupal.org/project/stage_file_proxy
  • 48. Features ● Features allows modules to be made that create Content Types, Fields, Views, Contexts, Rules, and many more types of configuration ● Allows you to see when things have changed and allows easy deployment of new functionality ● Try to add as much configuration into code as possible ● Group like items together https://www.drupal.org/project/features
  • 50. opensource.com ● JavaScript aggregation is turned off (but not CSS?) ● Messy module directory structure (due to Panopoly distribution)
  • 51. Cisco Internet Of Everything ● Runs Drupal 7.24 (as seen from CHANGELOG.txt) ● Vulnerable to SA-CORE- 2014-005?
  • 52. belgium.be ● Lots of stuff done right ● CSS and JavaScript aggregation turned off
  • 53. Greater Than Games ● Runs Drupal 7.41, as seen in CHANGELOG.txt ● Multi-site setup
  • 54. Elite Dangerous Community Site ● CSS/JavaScript aggregation is turned off ● Some use of Path Auto so URL’s like ‘node/123’ are common ● Multi-site setup ● Hacked the Bootstrap theme to make a sub-theme ● Call me! :)
  • 55. Top Tips Some things to take away with you
  • 56. Top Tips ● Have a go live plan ● Think about the experience of all of your users ● Don’t overcomplicate simple functionality ● Don’t use specific templates, generalise ● Think about the long term life of the site ● Learn the system (i.e. Drupal)

Editor's Notes

  1. Who am I to tell you what to be doing with your Drupal sites?
  2. This is a talk born from frustration frustration of sites being so broken that they just need throwing away and starting again frustration of drupal being hacked to make it work like an amature So what is the problem? Stems from the ability of people to build Drupal sites with little or no knowledge. Drupal is a tool like any other, and there is a right way and a wrong way. In the PHP world there is this saying...
  3. Drupal is a great tool, it’s quite easy to get up and running quickly But it’s really easy to build a Drupal site that is an unmaintainable mess Drupal: The Right Way?
  4. Main problem is when doing updates. Split the module from one site into another, which site is running what module.
  5. Think of MVC, but in this case it’s Entity, Theme, Menu hook? Model is the Entity View is the Theme Controller is the menu_hook Drupal 8 and Twig
  6. what happens when things change? what happens when you move from dev to production, will be IDs be the same?
  7. file parameter is in menu, theme, as the most notable examples, and a few other things It’s not just about how Drupal it put together, but also about the file structure within a module
  8. often come across custom modules that have no explanation of what they are doing, even in comments in the code don’t rely on the code being the documentation
  9. understand how Drupal is put together and understand how it can be overridden seen examples of: - random scripts being placed next to drupal that aren’t in modules or things like that - the book module being rebuilt - cache modules being created from scratch - Solr modules being built from scratch - API integration modules being rebuilt from scratch “re-invent the wheel, often” but own your own time!
  10. Some tips on getting the most out of your coding
  11. I still see this quite a lot
  12. commit messages must be present should also contain an indication of what changed and why it was changed
  13. git flow is also a good mechanism to control git branching
  14. settings.php file can be used to store certain module configuration options so it can be added to the repo in which case the local override block should be added this local settings technique is part of Drupal 8 core now
  15. notepad isn’t enough notepad++ is better, still not enough in my opinion Notable examples are Netbeans, Eclipse or PHPStorm Might be regarded as bloat-ware by some, but code navigation, debugging and autocomplete are essential for my sanity
  16. Linux vs Windows for development and production versions of software might cause problems, so installing the same version of X on both systems helps iron out issues in the future also think about PHP settings and real world data, will your site be able to cope?
  17. don’t forget about the error logs in Drupal make sure to set the error message printing to an appropriate level
  18. mainly simple things like: - the number of spaces in code -
  19. Cyclomatic complexity is a good heuristic of the complexity of the code this figure can be set anything above 10 is going to be hard to figure out! PHPMD will also point out where potential code problems might occurr unused variables in code variable names being too long or too short excessive function lengths Think about the next person who will look at the code. when writing complex code there is something you should understand...
  20. this also applies to yourself
  21. modules like display suite provide a nice approach to templates
  22. An example of a complex node would be An Event A gallery A news item with multiple control fields (e.g. for permissions) However, a few things to watch out for Don’t include 50+ images into a single node If you have to edit the php.ini to use 200MB+ uploads then you are doing it wrong
  23. drupal has poor logging built in, so seeing who altered some item of content can be hard avoid audit knightmare by restricting your users
  24. what happens when you have a View with some PHP filter stuff in it? Or a Node with some PHP filter code as the content? Where is the code being executed from? what about hooks?
  25. the graph shows the time taken to execute the cron before and after
  26. this can often lead to problems where a module expects certain parameters/ fields or whatever to be in place, which aren’t, errors are caused as a result
  27. Don’t add a new View for every page that it should appear on creates an administration headache Remember about Views caching, but be fully aware of what it does cached for everybody means that content generated by one user will be seen by all users so if you have any user specific stuff it will be seen by all users Views is powerful, but remember that there is a right and a wrong way to override views. the wrong way can easily cause errors and security holes
  28. and lots more!
  29. further reduces the footprint of your site
  30. saves CPU cycles
  31. It slows down your sites with: - profiling code - inspection code At Access we automatically detect for the presence of dpm() calls and fail the build if any are found
  32. for example, with a new feature you would have the content type extra fields vocabularies views
  33. this isn’t about pointing out problems with other sites, it’s about being easily able to see problems just from inspecting the front end code i’ll show that the problems i have gone over here can be easily seen in live sites i’m not making this stuff up!
  34. In reality, most of the big Drupal sites do a lot of stuff right and finding sites that are really broken is often rare
  35. misses out the latest securty patches
  36. I want to go on record by saying that I freaking love Elite dangerous this site is fucking atrocious! I dread to think what is going on inside i wonder if the code is as bad? if anyone knows who is in charge then get them to give me a ring