5 Secrets to Becoming a Drupal Ninja

Shane Thomas

Twitter: @smthomas3
Drupal.org: smthomas
Email: shane [at] codekarate [dot] com

Who am I?

  • Founder of codekarate.com - Hundreds of videos (Daily Dose of Drupal) and blog posts
  • Chief Technical Ninja at STEM Fuse - Build K-12 STEM curriculum
  • Previously owned a Drupal powered website development company

Who are you?

  • Someone with basic Drupal knowledge
  • Want to take your Drupal development up a notch

What is a Drupal Ninja?

A Drupal ninja is a Drupal developer, designer, or site builder that strives for efficiency and best practices. Spends time prior to the development phase of a project to sharpen their tools and craft effective development processes.

What are the 5 secrets?

  • Tips to improve your Drupal development
  • Not revolutionary (you have probably heard of some of these)
  • What I wish I knew 5 years ago

Based on my 200+ page Ebook

Available on codekarate.com

Secret #1: Code Editing

Find the right Code Editor for you

Why is it important?

  • The more time you spend in Drupal, the more time you will spend with your editor
  • A good code editor can make you more efficient

Some Code Editors to consider

Komodo Edit

My code editor of choice. I would highly recommend it to anyone.

Eclipse

Free, flexible, and highly extensible IDE.

Vim

For those who don't like to use your mouse. Lots of shortcuts and features.

PHPStorm

I have been hearing a lot of buzz about this one lately. Not free, but is a full IDE.

A lot more where that came from

More editors to look at - http://drupal.org/node/147789

Komodo Edit Features

The secret sauce that makes it great.

Syntax Highlighting

For just about any language you can think of

Code Completion

Code Snippets

It's not the tool, it's how you use it!

Secret #2: Drush

Command Line Kung Fu

According to the Drush GitHub page:

Drush is a command-line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those who spend their working hours hacking away at the command prompt.

Drush speeds up Drupal development and site maintenance

What can it do?

  • Download/Install Drupal
  • Download/Install modules/themes
  • Clear the Drupal Cache
  • Run Cron
  • Backup/Restore Drupal database
  • ...and much more

Installing Drush

  • Available for Linux, Mac, and Windows
  • Simple installation process but differs depending on your OS

Oh no, the Command Line!

It's not as scary as it seems.

Downloading Drupal

Drush Command What does it do?
drush dl drupal
Download a fresh copy of the latest stable Drupal 7 release.

Installing Drupal

Drush Command What does it do?
drush site-install standard --db-url=mysql://[MySQLUser]:[MySQLPassword]@localhost/[MySQLDatabase]
Installs Drupal 7 website.
Note: this defaults your username to admin and gives you a random password.

Download/Install modules

Drush Command What does it do?
drush dl [project-name]
Downloads a Drupal module or theme. The name can be grabbed from the drupal.org project name. For example in https://drupal.org/project/module_filter the project name is module_filter
drush en [module-name]
Installs a Drupal module. Keep in mind when you download a Drupal module, it may contain multiple modules. You can get the correct module name from the output of the drush dl command.

Clear Drupal Cache

Drush Command What does it do?
drush cc
Clear the Drupal cache
drush cc all
Clear all of the available Drupal caches.

Only the beginning

Learn about other commands - http://drush.ws/

Secret #3: Git

Tracking and managing code changes over time

A couple questions

  • Have you heard of version control?
  • Are you using version control?
  • Are you using version control the "right" way?

What is Git?

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

Why use a Version Control System?

  • Track changes to files over time
  • Great for multiple developer projects
  • Keep track of who changed what, and when
  • Easily roll back changes

How do I use Git?

WHAT! More Command Line?

Yes... More Command Line

Configure Git

Git Command What does it do?
git config --global user.name [name]
Configure the username for Git to use for the current logged in user.
git config --global user.email [email_address]
Configure the user email address for Git to use for the current logged in user.

Creating your First Repository

Git Command What does it do?
git init
Creates a Git repository in the current directory.
git init [folder]
Creates a new directory and Git repository.

Viewing your project status

Git Command What does it do?
git status
View status information about your current Git repository.

Creating a file

Viewing the project directory

Adding Files to your repository

Git Command What does it do?
git add [file]
Add a specific file to the Git staging area of your repository.
git add .
Add all new/modified files inside the current directory to the staging area of your repository.

Committing Your Changes

Git Command What does it do?
git commit
Commits all changes from the Git staging area, and launches a text editor to create a commit message. Save and close the text editor to complete the commit.
git commit -m “My commit message goes here"
Commits all changes from the Git staging area with the corresponding commit message.

Only scratching the surface

  • Pushing to hosted Git services like Github or Bitbucket
  • Git branches
  • Merging
  • Fixing conflicts

Learn more about Git - http://git-scm.com/

Secret #4: Development Process and Hosting

Craft your development process and integrate with your hosting provider

Your development process and your hosting provider are NOT synonymous, however they should be connected.

Do these sound familiar?

  • I make my changes directly on my live website
  • I don't really need a development site
  • I just test things after I make the change
  • What is "testing"?

Why define a development process

  • Improved quality
  • Test before you launch
  • Rollback plan if something breaks
  • Peace of mind

A two step development process

A three step development process

How are these sites used?

  • Development - Make your changes and initial testing
  • Stage - Client/end user testing
  • Live - For the world to see

Define your release/deployment process

It is not enough to just have three environments, if you are not sure how to move your changes between those environments.

A simplified development release process

On the Development site:

  1. Develop your new features, update contributed modules, modify the theme, or do any other type of code changes necessary.
  2. You add these changes to your Git staging area using the git add command.
  3. Next you commit these changes to your Git repository using the git commit command.
  4. Finally you push your changes up to your Git hosting service using the git push command.

On the Live site (or staging site):

  1. Pull down the most recent changes to the repository using the git pull command.
  2. Run the drush updatedb command. This will perform any necessary database updates and clear the Drupal cache.

Choose your hosting provider

The hosting of your website should integrate into your development process.

Acquia Cloud

Pantheon

Other alternatives

  • Managed Hosting - environment is set up and managed for you, but you have access to the server (BlackMesh, FireHost).
  • VPS - gives you the most control (Linode, Amazon AWS)
  • Shared Hosting - the most affordable option (BlueHost, Green Geeks, GoDaddy)

Which one is right for your project?


Drumroll please.... It Depends!

Secret #5: Features

Manage your site configuration with code

What is a Features module?

  • Export site configuration into a Drupal module
  • Allows configuration data to be migrated across environments (dev, staging, live).

What configuration is stored in the Drupal database?

  • Content Types
  • Views
  • Panels
  • Module configuration settings
  • ...Much more

The wrong way to configure a site

What do we need to fix it?

The right way

How it really works

Features module interface

Want to learn more about Features?

5 Secrets Summary

  1. Code Editor
  2. Drush
  3. Git
  4. Development Process
  5. Features Module

Want to learn more?

Use coupon code TWINCITIES when purchasing the
5 Secrets ebook (http://codekarate.com/product/5secrets) to get $3 off.

Drupal can seem intimidating

"Men wanted for hazardous journey. Low wages, bitter cold, long hours of complete darkness. Safe return doubtful. Honour and recognition in event of success."

- ERNEST SHACKLETON -

Questions?