Slide 1

Slide 1 text

March  3rd,  2013   MidwestPHP   1   E-­‐mail:  [email protected]   Twitter:  @dragonmantank   App.net:  @ctankersley   http://joind.in/talk/view/8227  

Slide 2

Slide 2 text

¡  Chris  Tankersley   ¡  Doing  PHP  for  9  Years   ¡  Lots  of  projects  no  one  uses,  and  a  few  that   some  do   §  TL;DR  https://github.com/dragonmantank   ¡  Heavy  Drupal  Development  for  2  years   March  3rd,  2013   MidwestPHP   2  

Slide 3

Slide 3 text

What  powers  your  site   March  3rd,  2013   MidwestPHP   3  

Slide 4

Slide 4 text

¡  Pre-­‐built  *AMP  Stack   ¡  Available  for  Drupal  6  or  7   ¡  Install  and  Ready  to  Go   March  3rd,  2013   MidwestPHP   4   Advantages   Disadvantages   ¡  Not  built  for  multiple  installs   ¡  Can’t  use  for  existing  sites   ¡  Only  for  Windows  and  Mac  

Slide 5

Slide 5 text

¡  Best  to  use  for  module  or  theme   development   ¡  I  don’t  like  it  for  full  site  development   March  3rd,  2013   MidwestPHP   5  

Slide 6

Slide 6 text

¡  Make  use  of  the  “Sites”  option  to  help   separate  work   ¡  On  Mac,  only  the  /sites/all/  folder  is  writable   §  Even  Sites  you  create  are  not  writable   ¡  Don’t  put  the  entire  stack  in  VC,  just  your   work   March  3rd,  2013   MidwestPHP   6  

Slide 7

Slide 7 text

March  3rd,  2013   MidwestPHP   7   ¡  Full  server  to  run  code   ¡  Self  contained  and  can  be  replicated   ¡  Most  modern  machines  can  do  VM   Advantages   Disadvantages   ¡  Uses  more  resources   ¡  Easier  to  break  

Slide 8

Slide 8 text

¡  Best  to  use  for  full  site  development   ¡  Or  use  it  all  the  time,  it’s  nice  to  have  an   environment  you  control   March  3rd,  2013   MidwestPHP   8  

Slide 9

Slide 9 text

¡  Try  and  pick  a  distro  that  is  close  to  your  production   setup.  If  you  are  running  Redhat  in  production,  set  up   an  CentOS  box   ¡  Set  up  the  document  root  for  your  web  server  to  be   the  /vagrant  folder  (or  sub  folder,  depending  on  your   site  layout).  This  way  your  site  will  run  automatically.   ¡  If  you  are  running  CentOS  and  Apache,  disable   SELinux  so  that  Apache  will  use  the  /vagrant  folder   ¡  Don't  use  PHP  5.4  with  Drupal  7  or  lower   ¡  Make  sure  APC,  or  some  opcode  cache,  is  installed   ¡  Provide  lots  of  RAM,  at  least  1GB   March  3rd,  2013   MidwestPHP   9  

Slide 10

Slide 10 text

¡  Run  everything  off  of  your  local  machine!   ¡  Great  if  you  can  do  it,  I  like  vagrant  better   March  3rd,  2013   MidwestPHP   10  

Slide 11

Slide 11 text

@grmpyprogrammer  will  track  you  down  if  you  don’t   March  3rd,  2013   MidwestPHP   11  

Slide 12

Slide 12 text

Automatically  making  sure  your  code  works   March  3rd,  2013   MidwestPHP   12  

Slide 13

Slide 13 text

¡  Write  your  tests  before  you  code   ¡  Watch  it  fail   ¡  Write  code  to  make  your  tests  pass   ¡  Feel  better   March  3rd,  2013   MidwestPHP   13  

Slide 14

Slide 14 text

¡  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   March  3rd,  2013   MidwestPHP   14  

Slide 15

Slide 15 text

March  3rd,  2013   MidwestPHP   15  

Slide 16

Slide 16 text

¡  Unit  tests  do  not  bootstrap  Drupal,  so  are   very  quick   ¡  Functional  Tests  bootstrap  Drupal,  so  are  very   slow   March  3rd,  2013   MidwestPHP   16  

Slide 17

Slide 17 text

¡  The  test  runner  is  AJAX,  so  it  can  break  very   easily   ¡  Debugging  can  be  hard  since  extra  output   breaks  the  test  runner,  and  since  the  DB  is   destroyed  watchdog()  is  useless   §  You  can  use  $this-­‐>verbose(‘message’)  or   debug(‘message’)  though   March  3rd,  2013   MidwestPHP   17  

Slide 18

Slide 18 text

Your  command  line  friend   March  3rd,  2013   MidwestPHP   18  

Slide 19

Slide 19 text

Dump  your  database  to  an  SQL  file   $  drush  sql-­‐dump  -­‐-­‐result-­‐file=/PATH/TO/dump.sql     Back  up  the  entire  site  to  a  tarball   $  drush  archive-­‐dump  default     View  watchdog  entries   $  drush  watchdog-­‐list     Update  Drupal  and  modules   $  drush  pm-­‐update     Download  module   $  drush  pm-­‐download  [module_name]   March  3rd,  2013   MidwestPHP   19  

Slide 20

Slide 20 text

I  couldn’t  think  of  a  good  tagline  that  should  go  here   March  3rd,  2013   MidwestPHP   20  

Slide 21

Slide 21 text

¡  Allows  you  to  quickly  back  up  the  DB  and   move  it   ¡  No  need  to  use  a  DB  GUI   ¡  Can  do  automatic  local  or  remote  backups   ¡  Useful  for  moving  databases  from  one  server   to  another   March  3rd,  2013   MidwestPHP   21  

Slide 22

Slide 22 text

¡  Exposes  a  lot  of  the  structure  of  Drupal   §  Things  like  nodes  can  be  clicked  through  to  see   their  object  structure   ¡  Can  auto-­‐generate  dummy  content   ¡  Better  debugging  output   §  dpm()  and  dvm()  for  pretty  output   §  dpr(),  kpr(),  and  dvr()  will  dump  to  the  page   header   March  3rd,  2013   MidwestPHP   22  

Slide 23

Slide 23 text

¡  Package  system  for  Drupal   ¡  Takes  a  lot  of  stuff  in  the  DB  and  makes  it   exportable  and  portable  via  code   ¡  Lot  of  stuff  works  out  of  the  box,  extra   modules  like  UUID,  boxes,  and  features_extra   pick  up  the  slack   ¡  ftools  makes  updating  features  easy   March  3rd,  2013   MidwestPHP   23  

Slide 24

Slide 24 text

Understand  it  and  harness  its  power   March  3rd,  2013   MidwestPHP   24  

Slide 25

Slide 25 text

¡  Page  caching  for  full  output  caching   ¡  Block  caching  so  that  dynamic  content  can   still  update  if  it  needs  to   ¡  You  can  configure  how  long  to  cache  things   for   March  3rd,  2013   MidwestPHP   25  

Slide 26

Slide 26 text

¡  In  Full  Page  Caching,  most  of  the  PHP  isn’t   run   §  Effectively  turns  your  site  into  a  static  site  (kind   of)   ¡  With  block  caching,  not  all  blocks  will  cache.   What  and  when  to  cache  is  up  to  the  block   March  3rd,  2013   MidwestPHP   26  

Slide 27

Slide 27 text

It’s  kind  of  like  nuclear  fusion,  but  without  all  the  explosions   March  3rd,  2013   MidwestPHP   27  

Slide 28

Slide 28 text

¡  Will  group  needed  JS  and  CSS  files  together,   reducing  the  number  of  HTTP  requests   ¡  Will  minify  CSS,  reducing  some  of  the   transmission  size   YOU  have  to  make  your  modules  take   advantage  of  it,  though   March  3rd,  2013   MidwestPHP   28  

Slide 29

Slide 29 text

¡  Let  Drupal  know  about  your  files   §  drupal_add_js()   §  drupal_add_css()   §  Add  the  files  to  your  .info  file   ¡  Don’t  just  add  JS  and  CSS  files  via     and  <style>  tags  in  your  theme   March  3rd,  2013   MidwestPHP   29  

Slide 30

Slide 30 text

Really,  ask.     March  3rd,  2013   MidwestPHP   30  

Slide 31

Slide 31 text

¡  Acquia  Dev  Desktop   ¡  vagrant   ¡  Drupal  SimpleTest   ¡  drush   ¡  Backup  and  Migrate   ¡  Devel   ¡  Features   March  3rd,  2013   MidwestPHP   31  

Slide 32

Slide 32 text

March  3rd,  2013   MidwestPHP   32   E-­‐mail:  [email protected]   Twitter:  @dragonmantank   App.net:  @ctankersley     http://joind.in/talk/view/8227