ENVIRONMENTS &VERSION CONTROL   The Why & How                   ERIKREAGAN • EECI
WHO IS THIS GUY?        EE Reactor team member2                                ERIKREAGAN • EECI
WHO IS THIS GUY?        Partner & Lead Developer3                                  ERIKREAGAN • EECI
Survey Submissions4    78                   ERIKREAGAN • EECI
SURVEY SUBMISSIONS                              Web Development Experience    35   6-10 years    24   3-5 years    19   Ov...
SURVEY SUBMISSIONS                           ExpressionEngine Experience    40    3-4 years     19   0-2 years     12   5-...
SURVEY SUBMISSIONS                                    Weekly Responsibilities    66    HTML/CSS/JS markup    64    EE site...
Caught my Monty Python reference8    73%                         ERIKREAGAN • EECI
VERSION CONTROL9              ERIKREAGAN • EECI
SYNONYMS     • Version Control     • Revision Control     • Source Control10                        ERIKREAGAN • EECI
COMMON SYSTEMS     • Git     • Subversion     • Mercurial11                  ERIKREAGAN • EECI
SURVEY STATS12             ERIKREAGAN • EECI
Devs not currently using a VCS regularly13     34%                               ERIKREAGAN • EECI
Devs only using a desktop GUI for VCS14     21%                             ERIKREAGAN • EECI
Devs only using command line for VCS15     21%                            ERIKREAGAN • EECI
Devs using both CLI and a GUI for VCS16     24%                            ERIKREAGAN • EECI
Have used CVS17     6%              ERIKREAGAN • EECI
Have used Mercurial18     13%                   ERIKREAGAN • EECI
Have used Subversion19     54%                ERIKREAGAN • EECI
Have used Git20     77%             ERIKREAGAN • EECI
WE USE GIT     Linux    jQuery   Rails   Android21                             ERIKREAGAN • EECI
WE USE GIT              And so do the cool kids     Linux     jQuery       Rails       Android21                          ...
WE USE GIT              And so do the cool kids     Linux     jQuery       Rails       Android21                          ...
OLD WAY                                 Single Developer     1. Duplicate index.html     2. Test changes     3. (Maybe sav...
NEW WAY                                      Single Developer     1. Change and save the file contents         (Retain hist...
OLD WAY                              Development Team     1. Bob changes part of index.html     2. Suzie changes a differen...
NEW WAY                                      Development Team     1. Change and save the file contents         (Retain hist...
26   ERIKREAGAN • EECI
26   ERIKREAGAN • EECI
26   ERIKREAGAN • EECI
KEY CONCEPTS     • Track certain files     • Ignore certain files     • Commits (History)     • Branches     • Remote branch...
“WHAT DO I TRACK?”             VS     “WHAT DO I IGNORE?”28                 ERIKREAGAN • EECI
IGNORED FILES     • Operating System files     • Caches     • .htaccess (possibly)     • Custom uploads from EE     • Dynam...
.gitignore     # Lame OS files     Thumbs.db     .DS_Store     # EE System cache     /system/expressionengine/cache/*     ...
TRACKED FILES     • EE System directory     • Add-ons     • Template flat files     • Images, CSS, Javascript & other assets...
COMMITS     Create your history32                         ERIKREAGAN • EECI
COMMIT TIPS     • Commit o en (common Git practice)     • Write detailed commit messages     • Review commit log when retu...
BAD COMMIT MESSAGE     Updated config file.34                          ERIKREAGAN • EECI
GOOD COMMIT MESSAGE     Updated config file with new Minimee cache path     directory     This allows our cache path to be...
BRANCHING      Keeping things organized36                               ERIKREAGAN • EECI
BRANCHING      WORKFLOW         Do what works best for you     Just make sure you do it for a reason37                    ...
REMOTE BRANCHES     • Destination for your repository / branch     • “Origin” of your repository / branch     • Server env...
TOPICAL BRANCHING     • master     • dev     • feature/x     • upgrade/y     • bugfix/z39                 ERIKREAGAN • EECI
“Its like not wearing a seatbelt in       your car because you havent had       an accident yet.       Dont be silly, vers...
GIT RESOURCES     • Book: Pragmatic Version Control Using Git     • peepcode.com/products/git     • whygitisbetterthanx.co...
ENVIRONMENTS42             ERIKREAGAN • EECI
AN ENVIRONMENT IS      any server running an instance of your site43                                        ERIKREAGAN • E...
COMMON     ENVIRONMENTS     • Production - the public-facing “live” site     • Staging - typically used for a final test   ...
SURVEY STATS45             ERIKREAGAN • EECI
Devs currently using a Production Environment100%46                                       ERIKREAGAN • EECI
Devs currently using a Staging Environment47     59%                               ERIKREAGAN • EECI
Devs currently using a Shared Dev Environment48     32%                                 ERIKREAGAN • EECI
Devs currently using a Local Dev Environment49     77%                                ERIKREAGAN • EECI
Devs who keep using environments post-launch50     29%                                ERIKREAGAN • EECI
WHY DO YOU USE     ENVIRONMENTS?51              ERIKREAGAN • EECI
“Local development is incredibly     fast and you dont have to worry     about setting up crazy conditionals     and memeb...
“Multiple environments allow us to     build locally without affecting others     and preview new features to clients -    ...
“Automated deployments and     multiple environments are essential     to any agile-oriented developer.     They save time...
GETTING SET UP     What is potentially unique to each environment?55                                        ERIKREAGAN • E...
GETTING SET UP                                          What’s Unique?     • Server paths     • URL root     • EE upload p...
ROBUST CONFIG FILE        Saves time and adds flexibility57                                   ERIKREAGAN • EECI
GETTING SET UP                                    What can be changed?     ✓ Server paths     ✓ URL root     - EE upload p...
GETTING SET UP                              Directory and file structure     /config/        config.env.php        config.m...
GETTING SET UP                                                      config.env.php sample     if ( ! defined(ENV))     {   ...
GETTING SET UP                                                                     config.dev.php sample     <?php if ( ! d...
GETTING SET UP                                                        config.master.php sample    /**     * Template settin...
GETTING SET UP                                                       config.master.php sample/** * Debugging settings * * T...
GETTING SET UP                                                     config.master.php sample     /**      * 3rd Party Add-on...
FOCUS LAB     CONFIG SETUP     github.com/focuslabllc/ee-master-config65                                   ERIKREAGAN • EECI
MULTI-ENVIRONMENT        CHALLENGES       You didn’t think it was that easy, did you?66                                   ...
BACK TO THE       SURVEY67            ERIKREAGAN • EECI
100%68      ERIKREAGAN • EECI
Keeping database changes synced across environments     100%68                                          ERIKREAGAN • EECI
72%69     ERIKREAGAN • EECI
Maintaining custom upload directory paths     72%69                                      ERIKREAGAN • EECI
Devs who say the headaches are worth the trouble 100%                                     ERIKREAGAN • EECI70
DATABASE ISSUES     • New custom fields alter the DB schema     • Installing or updating add-ons can alter the DB      sche...
DATABASE ISSUES     • Custom upload directory paths are stored in the DB      and cannot be dynamically altered     • Rela...
http://expressionengine.com/forums/viewthread/196480/73                                           ERIKREAGAN • EECI
QUICK TIPS     • You need to understand EE’s database     • Learn about 3rd party add-on’s DB tables     • Establish a rul...
Schema / Structureflows up stream75                   ERIKREAGAN • EECI
Content flowsdown stream76             ERIKREAGAN • EECI
FINAL NOTES     • These practices make you a better developer     • They help prepare you to work with a team     • They h...
ERIKREAGAN     Partner Focus Lab LLC      FocusLabLLC78                           ERIKREAGAN • EECI
Upcoming SlideShare
Loading in …5
×

Environments and Version Control in EE - The Why and How

3,540 views

Published on

Published in: Technology
4 Comments
7 Likes
Statistics
Notes
No Downloads
Views
Total views
3,540
On SlideShare
0
From Embeds
0
Number of Embeds
16
Actions
Shares
0
Downloads
63
Comments
4
Likes
7
Embeds 0
No embeds

No notes for slide

Environments and Version Control in EE - The Why and How

  1. 1. ENVIRONMENTS &VERSION CONTROL The Why & How ERIKREAGAN • EECI
  2. 2. WHO IS THIS GUY? EE Reactor team member2 ERIKREAGAN • EECI
  3. 3. WHO IS THIS GUY? Partner & Lead Developer3 ERIKREAGAN • EECI
  4. 4. Survey Submissions4 78 ERIKREAGAN • EECI
  5. 5. SURVEY SUBMISSIONS Web Development Experience 35 6-10 years 24 3-5 years 19 Over 10 years5 ERIKREAGAN • EECI
  6. 6. SURVEY SUBMISSIONS ExpressionEngine Experience 40 3-4 years 19 0-2 years 12 5-7 years 4 pMachine 3 None6 ERIKREAGAN • EECI
  7. 7. SURVEY SUBMISSIONS Weekly Responsibilities 66 HTML/CSS/JS markup 64 EE site planning 38 PHP/MySQL development 21 Add-on development 20 Content management 19 Team leader7 ERIKREAGAN • EECI
  8. 8. Caught my Monty Python reference8 73% ERIKREAGAN • EECI
  9. 9. VERSION CONTROL9 ERIKREAGAN • EECI
  10. 10. SYNONYMS • Version Control • Revision Control • Source Control10 ERIKREAGAN • EECI
  11. 11. COMMON SYSTEMS • Git • Subversion • Mercurial11 ERIKREAGAN • EECI
  12. 12. SURVEY STATS12 ERIKREAGAN • EECI
  13. 13. Devs not currently using a VCS regularly13 34% ERIKREAGAN • EECI
  14. 14. Devs only using a desktop GUI for VCS14 21% ERIKREAGAN • EECI
  15. 15. Devs only using command line for VCS15 21% ERIKREAGAN • EECI
  16. 16. Devs using both CLI and a GUI for VCS16 24% ERIKREAGAN • EECI
  17. 17. Have used CVS17 6% ERIKREAGAN • EECI
  18. 18. Have used Mercurial18 13% ERIKREAGAN • EECI
  19. 19. Have used Subversion19 54% ERIKREAGAN • EECI
  20. 20. Have used Git20 77% ERIKREAGAN • EECI
  21. 21. WE USE GIT Linux jQuery Rails Android21 ERIKREAGAN • EECI
  22. 22. WE USE GIT And so do the cool kids Linux jQuery Rails Android21 ERIKREAGAN • EECI
  23. 23. WE USE GIT And so do the cool kids Linux jQuery Rails Android21 ERIKREAGAN • EECI
  24. 24. OLD WAY Single Developer 1. Duplicate index.html 2. Test changes 3. (Maybe save a backup of the previous version) 4. Save over old version losing previous state22 ERIKREAGAN • EECI
  25. 25. NEW WAY Single Developer 1. Change and save the file contents (Retain history of file for future use)23 ERIKREAGAN • EECI
  26. 26. OLD WAY Development Team 1. Bob changes part of index.html 2. Suzie changes a different part of index.html 3. Bob and Suzie carefully merge changes together 4. Overwrite old version of index.html24 ERIKREAGAN • EECI
  27. 27. NEW WAY Development Team 1. Change and save the file contents (Retain history of file for future use)25 ERIKREAGAN • EECI
  28. 28. 26 ERIKREAGAN • EECI
  29. 29. 26 ERIKREAGAN • EECI
  30. 30. 26 ERIKREAGAN • EECI
  31. 31. KEY CONCEPTS • Track certain files • Ignore certain files • Commits (History) • Branches • Remote branches27 ERIKREAGAN • EECI
  32. 32. “WHAT DO I TRACK?” VS “WHAT DO I IGNORE?”28 ERIKREAGAN • EECI
  33. 33. IGNORED FILES • Operating System files • Caches • .htaccess (possibly) • Custom uploads from EE • Dynamic images (captchas etc)29 ERIKREAGAN • EECI
  34. 34. .gitignore # Lame OS files Thumbs.db .DS_Store # EE System cache /system/expressionengine/cache/* # Local dev database file /config/config.local.php # Custom Upload Directories /public_html/uploads/* # Captchas /public_html/images/captchas # Asset minification /public_html/min30 ERIKREAGAN • EECI
  35. 35. TRACKED FILES • EE System directory • Add-ons • Template flat files • Images, CSS, Javascript & other assets31 ERIKREAGAN • EECI
  36. 36. COMMITS Create your history32 ERIKREAGAN • EECI
  37. 37. COMMIT TIPS • Commit o en (common Git practice) • Write detailed commit messages • Review commit log when returning to a project a er a break of any sort • Review commits of development team members33 ERIKREAGAN • EECI
  38. 38. BAD COMMIT MESSAGE Updated config file.34 ERIKREAGAN • EECI
  39. 39. GOOD COMMIT MESSAGE Updated config file with new Minimee cache path directory This allows our cache path to be dynamicly absolute based on the environment out code is in. $config[‘minimee_cache_path’] = $base_path . ‘/min’;35 ERIKREAGAN • EECI
  40. 40. BRANCHING Keeping things organized36 ERIKREAGAN • EECI
  41. 41. BRANCHING WORKFLOW Do what works best for you Just make sure you do it for a reason37 ERIKREAGAN • EECI
  42. 42. REMOTE BRANCHES • Destination for your repository / branch • “Origin” of your repository / branch • Server environment for your site • Other team member’s repository / branch38 ERIKREAGAN • EECI
  43. 43. TOPICAL BRANCHING • master • dev • feature/x • upgrade/y • bugfix/z39 ERIKREAGAN • EECI
  44. 44. “Its like not wearing a seatbelt in your car because you havent had an accident yet. Dont be silly, version your work.” Iain Urquhart / @iain40 ERIKREAGAN • EECI
  45. 45. GIT RESOURCES • Book: Pragmatic Version Control Using Git • peepcode.com/products/git • whygitisbetterthanx.com • github.com • More available with the presentation download41 ERIKREAGAN • EECI
  46. 46. ENVIRONMENTS42 ERIKREAGAN • EECI
  47. 47. AN ENVIRONMENT IS any server running an instance of your site43 ERIKREAGAN • EECI
  48. 48. COMMON ENVIRONMENTS • Production - the public-facing “live” site • Staging - typically used for a final test • Development - shared team development • Local - each developer’s local instance44 ERIKREAGAN • EECI
  49. 49. SURVEY STATS45 ERIKREAGAN • EECI
  50. 50. Devs currently using a Production Environment100%46 ERIKREAGAN • EECI
  51. 51. Devs currently using a Staging Environment47 59% ERIKREAGAN • EECI
  52. 52. Devs currently using a Shared Dev Environment48 32% ERIKREAGAN • EECI
  53. 53. Devs currently using a Local Dev Environment49 77% ERIKREAGAN • EECI
  54. 54. Devs who keep using environments post-launch50 29% ERIKREAGAN • EECI
  55. 55. WHY DO YOU USE ENVIRONMENTS?51 ERIKREAGAN • EECI
  56. 56. “Local development is incredibly fast and you dont have to worry about setting up crazy conditionals and memeber preferences to hide what you are working on on the live site.”52 ERIKREAGAN • EECI
  57. 57. “Multiple environments allow us to build locally without affecting others and preview new features to clients - without losing the ability to quickly apply updates to the current live site.”53 ERIKREAGAN • EECI
  58. 58. “Automated deployments and multiple environments are essential to any agile-oriented developer. They save time, reduce errors and streamline site maintenance.”54 ERIKREAGAN • EECI
  59. 59. GETTING SET UP What is potentially unique to each environment?55 ERIKREAGAN • EECI
  60. 60. GETTING SET UP What’s Unique? • Server paths • URL root • EE upload paths • Debug mode intentions • URI support (PATH_INFO) • Cache settings56 ERIKREAGAN • EECI
  61. 61. ROBUST CONFIG FILE Saves time and adds flexibility57 ERIKREAGAN • EECI
  62. 62. GETTING SET UP What can be changed? ✓ Server paths ✓ URL root - EE upload paths ✓ Debug mode intentions ✓ URI support (PATH_INFO) ✓Cache settings58 ERIKREAGAN • EECI
  63. 63. GETTING SET UP Directory and file structure /config/ config.env.php config.master.php config.{ENV}.php /public_html/ /system/ /tpl/59 ERIKREAGAN • EECI
  64. 64. GETTING SET UP config.env.php sample if ( ! defined(ENV)) { switch ($_SERVER[HTTP_HOST]) { case focuslabllc.com : define(ENV, prod); define(ENV_FULL, Production); define(ENV_DEBUG, FALSE); break; case ohsnap.focuslabllc.com : define(ENV, stage); define(ENV_FULL, Staging); define(ENV_DEBUG, FALSE); break; default : define(ENV, local); define(ENV_FULL, Local); define(ENV_DEBUG, TRUE); break; } }60 ERIKREAGAN • EECI
  65. 65. GETTING SET UP config.dev.php sample <?php if ( ! defined(BASEPATH)) exit(No direct script access allowed); /** * Development config overrides & db credentials * * Our database credentials and any environment-specific overrides * * @package Focus Lab Master Config * @version 1.1 * @author Erik Reagan <erik@focuslabllc.com> */ $env_db[hostname] = localhost; $env_db[username] = ; $env_db[password] = ; $env_db[database] = ; $config[webmaster_email] = dev@focuslabllc.com; /* End of file config.dev.php */ /* Location: ./config/config.dev.php */61 ERIKREAGAN • EECI
  66. 66. GETTING SET UP config.master.php sample /** * Template settings * * Working locally we want to reference our template files. * In staging and production we do not use flat files * (for ever-so-slightly better performance) * This approach requires that we synchronize templates after * each deployment of template changes */$env_config[save_tmpl_files] = (ENV == prod) ? n : y;$env_config[tmpl_file_basepath] = $base_path . /../tpl/;$env_config[hidden_template_indicator] = _;62 ERIKREAGAN • EECI
  67. 67. GETTING SET UP config.master.php sample/** * Debugging settings * * These settings are helpful to have in one place * for debugging purposes */$env_config[is_system_on] = y;$env_config[allow_extensions] = y;$env_config[email_debug] = (ENV_DEBUG) ? y : n ;// Show template debugging if were not in production$env_config[template_debugging] = (ENV_DEBUG) ? y : n ;/** * Set debug to 2 if were in dev mode, otherwise just 1 * * 0: no PHP/SQL errors shown * 1: Errors shown to Super Admins * 2: Errors shown to everyone */$env_config[debug] = (ENV_DEBUG) ? 2 : 1 ;63 ERIKREAGAN • EECI
  68. 68. GETTING SET UP config.master.php sample /** * 3rd Party Add-on config items as needed */ $env_config[minimee_cache_path] = $base_path . /min; $env_config[minimee_cache_url] = $base_url . /min; $env_config[minimee_remote_mode] = auto; $env_config[minimee_debug] = n; // Disable minimee in dev but not in staging and production $env_config[minimee_disable] = (ENV == local) ? y : n ; // Greeny (auto-updating of upload directory paths) $env_config[greeny_enabled] = (ENV == prod) ? false :64 ERIKREAGAN • EECI
  69. 69. FOCUS LAB CONFIG SETUP github.com/focuslabllc/ee-master-config65 ERIKREAGAN • EECI
  70. 70. MULTI-ENVIRONMENT CHALLENGES You didn’t think it was that easy, did you?66 ERIKREAGAN • EECI
  71. 71. BACK TO THE SURVEY67 ERIKREAGAN • EECI
  72. 72. 100%68 ERIKREAGAN • EECI
  73. 73. Keeping database changes synced across environments 100%68 ERIKREAGAN • EECI
  74. 74. 72%69 ERIKREAGAN • EECI
  75. 75. Maintaining custom upload directory paths 72%69 ERIKREAGAN • EECI
  76. 76. Devs who say the headaches are worth the trouble 100% ERIKREAGAN • EECI70
  77. 77. DATABASE ISSUES • New custom fields alter the DB schema • Installing or updating add-ons can alter the DB schema • Updating EE can alter the DB schema71 ERIKREAGAN • EECI
  78. 78. DATABASE ISSUES • Custom upload directory paths are stored in the DB and cannot be dynamically altered • Relative upload directory paths work sometimes, but not with all add-ons • “Content” is very likely changing in the Production environment while you build and test in your other environments72 ERIKREAGAN • EECI
  79. 79. http://expressionengine.com/forums/viewthread/196480/73 ERIKREAGAN • EECI
  80. 80. QUICK TIPS • You need to understand EE’s database • Learn about 3rd party add-on’s DB tables • Establish a ruleset for your workflow • Understand that there will be exceptions74 ERIKREAGAN • EECI
  81. 81. Schema / Structureflows up stream75 ERIKREAGAN • EECI
  82. 82. Content flowsdown stream76 ERIKREAGAN • EECI
  83. 83. FINAL NOTES • These practices make you a better developer • They help prepare you to work with a team • They help your team work more efficiently • You can provide a better service to your clients77 ERIKREAGAN • EECI
  84. 84. ERIKREAGAN Partner Focus Lab LLC FocusLabLLC78 ERIKREAGAN • EECI

×