2. 2
Who Am I?
● A PHP Developer for 10 Years
● Drupal Dev for 4 years
● Lots of projects no one uses, and a few
some do
● https://github.com/dragonmantank
3. 3
We've got a lot to cover
● Development Environments
● Version Control
● drush
● Coding Standards
● Building Better Modules
● Moving Out of the Database
● Putting it all together
8. 8
If you have to...
● Acquia Dev Desktop
● Zend Server
9. 9
Acquia Dev Desktop
● Pre-built *AMP Stack
● Available for Drupal 6 or 7
● Install and Ready to Go
10. 10
Acquia Dev Desktop
● Not built for multiple installs
● Can’t use for existing sites
● Only for Windows and Mac
11. 11
Zend Server
● Uses OS's server
● Has some cool tools like Z-Ray
● Mostly a wrapper around the local stack
● Support!
● Has a Development and Production
version
12. 12
Zend Server
● Weird issues with permissions
● Works best with other Zend tools
● Pricey
13. 13
How it looks
Your OS
Applications
Your App
Web Server DB Server
14. 14
docker
● Containers for applications
● Makes deployment very easy
● Very easy to get set up
● Way more performant than VMs
15. 15
docker
● If you're not on Linux, think really hard
about using
● Mostly a deployment fixer
16. 16
How it looks - Linux
Your OS
Applications
Your App
Web Server DB Server
17. 17
How it looks – Everywhere Else
Your App
Web Server DB Server
Virtualized OS
Applications Virtualization Layer
Your OS
18. 18
vagrant
● Full server to run code
● Self contained and can be replicated
● Most modern machines can do VM
19. 19
vagrant
● Uses more resources
● Easier to break
● When it breaks, it breaks hard
20. 20
How it looks
Your App
Web Server DB Server
Virtualized OS
Applications Virtualization Layer
Your OS
22. 22
Considerations
● How special is my Production environment?
● What resources do my dev machines have?
● How many things am I working on?
● What's the tech level of my coworkers?
● What's the tech level of my clients?
35. 35
For more info...
http://nvie.com/posts/a-successful-git-branching-model/
36. 36
Jeff Carouth's „Git and Github – Working
Effectively on a Team“
https://speakerdeck.com/jcarouth/git-and-github-
working-effectively-on-a-team-at-php-tek-
2014
47. 47
Run a development server
$ drush runserver 8080
$ drush runserver 0.0.0.0:8080
48. 48
Watching the Watchdog
// Show the last 10 messages
$ drush watchdog-show
// Show the last 50 messages
$ drush watchdog-show --count=50
// Show only entries of a specific severity
$ drush watchdog-show --severity=notice
// Search for a specific message
$ drush watchdog-show "cron run successful"
49. 49
Viewing Watchdog Entries
$ drush watchdog-show 54
ID : 54
Date : 30/Jan 22:10
Type : system
Severity : info
Message : overlay module disabled.
50. 50
Cleaning Up After the (Watch)dog
// Destroy it all!
$ drush watchdog-delete all
// Delete a specific one to hide an error you generated that no one can know about
$ drush watchdog-delete 50
// Delete all messages containing a string
$ drush watchdog-delete "cron run successfull"
// Delete everything of a specific severity
$ drush watchdog-delete --severity=debug
51. 51
Working with modules
$ drush pm-download backup_migrate
$ drush pm-enable backup_migrate
$ drush pm-update
52. 52
drush Aliases
● Allows you to tell drush where an
external site is located at
● Requires drush on the other end, and
shell access
54. 54
Using an alias
$ drush @prod status
PHP configuration : /Applications/acquia-drupal/php5_3/bin/php.ini
Drush version : 5.7
Drush configuration :
55. 55
Common uses for aliases
$ drush rsync sites/default/files/ @prod:sites/default/files
$ drush sql-sync @prod @self
$ drush @prod site-install standard [...]
56. 56
Deploying code with drush
$ drush rsync @self @prod
You will destroy data from ctankersley@10.0.2.2:'~/Sites/deploy/' and
replace with data from /vagrant/
Do you really want to continue? (y/n): y
59. 59
Huh?
Coding standards are a list of rules regarding
the layout and structure of source code.
60. 60
What?
● Two space indents
● Spaces between casts
– $id = (int) $_POST['id'];
● Not using else if, using elseif
● Always using curly braces on control
structures
61. 61
Why?
● Makes it easy to read code
● Makes it easy to merge code
● You're on a team, act like it
● If you want your code on drupal.org, you're
going to need to follow it
● If you want to contribute, you'll need to follow it
62. 62
For the nitty-gritty...
● https://www.drupal.org/coding-standards
77. 77
How Test Driven Development works
● Write your tests before your code
● Watch it fail
● Write code to make your test pass
● Feel better! (and refactor)
78. 78
TDD In Drupal
● Drupal ships with SimpleTest baked in
● Supports unit testing and functional testing
● Unit tests are done by extending
DrupalUnitTestCase
● Functional tests are done by extending
DrupalWebTestCase
79. 79
Unit Tests vs Functional Tests
● Unit tests should focus on testing an
individual piece of code
● Functional tests should focus on testing
output/pages
80. 80
Unit Tests vs Functional Tests
● Unit tests do not bootstrap Drupal, so
are very quick
● Functional tests do bootstrap Drupal, so
are very slow
81. 81
Downsides to TDD in Drupal
● The GUI is an AJAX runner, which breaks a lot
– Use drush for a better experience
● Debugging can be very hard, since the
environment is created and destroyed each
test
– Use $this->verbose() or debug()
87. 87
Caching
● Caching saves a chunk of the render
array to the DB
● Caching still requires a DB hit
88. 88
Two Different Caches
● Page caching for full output
● Block caching for dynamic content
89. 89
Asset Aggregation
● Groups CSS and JS together, reducing
HTTP calls
● Will minify the CSS, reducing the
transmission size
90. 90
Easy to take advantage of
● Let Drupal know about your files
– drupal_add_js()
– drupal_add_css()
– Through #attached
– Add it to your .info file
● Don't just add straight to templates