Slide 1

Slide 1 text

ERIKREAGAN • EECI ENVIRONMENTS & VERSION CONTROL The Why & How

Slide 2

Slide 2 text

ERIKREAGAN • EECI WHO IS THIS GUY? 2 EE Reactor team member

Slide 3

Slide 3 text

ERIKREAGAN • EECI WHO IS THIS GUY? 3 Partner & Lead Developer

Slide 4

Slide 4 text

Survey Submissions ERIKREAGAN • EECI 78 4

Slide 5

Slide 5 text

ERIKREAGAN • EECI 5 35 24 19 6-10 years 3-5 years Over 10 years SURVEY SUBMISSIONS Web Development Experience

Slide 6

Slide 6 text

ERIKREAGAN • EECI 6 40 19 12 4 3 3-4 years SURVEY SUBMISSIONS ExpressionEngine Experience 0-2 years 5-7 years pMachine None

Slide 7

Slide 7 text

ERIKREAGAN • EECI 7 66 64 38 21 20 19 HTML/CSS/JS markup SURVEY SUBMISSIONS Weekly Responsibilities EE site planning PHP/MySQL development Add-on development Content management Team leader

Slide 8

Slide 8 text

Caught my Monty Python reference ERIKREAGAN • EECI 73% 8

Slide 9

Slide 9 text

ERIKREAGAN • EECI VERSION CONTROL 9

Slide 10

Slide 10 text

ERIKREAGAN • EECI SYNONYMS • Version Control • Revision Control • Source Control 10

Slide 11

Slide 11 text

ERIKREAGAN • EECI COMMON SYSTEMS • Git • Subversion • Mercurial 11

Slide 12

Slide 12 text

ERIKREAGAN • EECI SURVEY STATS 12

Slide 13

Slide 13 text

Devs not currently using a VCS regularly ERIKREAGAN • EECI 34% 13

Slide 14

Slide 14 text

Devs only using a desktop GUI for VCS ERIKREAGAN • EECI 21% 14

Slide 15

Slide 15 text

Devs only using command line for VCS ERIKREAGAN • EECI 21% 15

Slide 16

Slide 16 text

Devs using both CLI and a GUI for VCS ERIKREAGAN • EECI 24% 16

Slide 17

Slide 17 text

Have used CVS ERIKREAGAN • EECI 6% 17

Slide 18

Slide 18 text

Have used Mercurial ERIKREAGAN • EECI 13% 18

Slide 19

Slide 19 text

Have used Subversion ERIKREAGAN • EECI 54% 19

Slide 20

Slide 20 text

Have used Git ERIKREAGAN • EECI 77% 20

Slide 21

Slide 21 text

ERIKREAGAN • EECI 21 WE USE GIT Linux jQuery Rails Android

Slide 22

Slide 22 text

ERIKREAGAN • EECI 21 WE USE GIT And so do the cool kids Linux jQuery Rails Android

Slide 23

Slide 23 text

ERIKREAGAN • EECI 21 WE USE GIT And so do the cool kids Linux jQuery Rails Android

Slide 24

Slide 24 text

ERIKREAGAN • EECI OLD WAY 1. Duplicate index.html 2. Test changes 3. (Maybe save a backup of the previous version) 4. Save over old version losing previous state 22 Single Developer

Slide 25

Slide 25 text

ERIKREAGAN • EECI NEW WAY 1. Change and save the file contents (Retain history of file for future use) 23 Single Developer

Slide 26

Slide 26 text

ERIKREAGAN • EECI OLD WAY 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.html 24 Development Team

Slide 27

Slide 27 text

ERIKREAGAN • EECI NEW WAY 1. Change and save the file contents (Retain history of file for future use) 25 Development Team

Slide 28

Slide 28 text

ERIKREAGAN • EECI 26

Slide 29

Slide 29 text

ERIKREAGAN • EECI 26

Slide 30

Slide 30 text

ERIKREAGAN • EECI 26

Slide 31

Slide 31 text

ERIKREAGAN • EECI KEY CONCEPTS • Track certain files • Ignore certain files • Commits (History) • Branches • Remote branches 27

Slide 32

Slide 32 text

ERIKREAGAN • EECI “WHAT DO I TRACK?” VS “WHAT DO I IGNORE?” 28

Slide 33

Slide 33 text

ERIKREAGAN • EECI IGNORED FILES • Operating System files • Caches • .htaccess (possibly) • Custom uploads from EE • Dynamic images (captchas etc) 29

Slide 34

Slide 34 text

ERIKREAGAN • EECI # 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/min 30 .gitignore

Slide 35

Slide 35 text

ERIKREAGAN • EECI 31 TRACKED FILES • EE System directory • Add-ons • Template flat files • Images, CSS, Javascript & other assets

Slide 36

Slide 36 text

ERIKREAGAN • EECI COMMITS Create your history 32

Slide 37

Slide 37 text

ERIKREAGAN • EECI 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 members 33

Slide 38

Slide 38 text

ERIKREAGAN • EECI BAD COMMIT MESSAGE Updated config file. 34

Slide 39

Slide 39 text

ERIKREAGAN • EECI 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

Slide 40

Slide 40 text

ERIKREAGAN • EECI BRANCHING Keeping things organized 36

Slide 41

Slide 41 text

ERIKREAGAN • EECI BRANCHING WORKFLOW Do what works best for you 37 Just make sure you do it for a reason

Slide 42

Slide 42 text

ERIKREAGAN • EECI REMOTE BRANCHES • Destination for your repository / branch • “Origin” of your repository / branch • Server environment for your site • Other team member’s repository / branch 38

Slide 43

Slide 43 text

ERIKREAGAN • EECI TOPICAL BRANCHING • master • dev • feature/x • upgrade/y • bugfix/z 39

Slide 44

Slide 44 text

ERIKREAGAN • EECI 40 “It's like not wearing a seatbelt in your car because you haven't had an accident yet. Don't be silly, version your work.” Iain Urquhart / @iain

Slide 45

Slide 45 text

ERIKREAGAN • EECI GIT RESOURCES • Book: Pragmatic Version Control Using Git • peepcode.com/products/git • whygitisbetterthanx.com • github.com • More available with the presentation download 41

Slide 46

Slide 46 text

ERIKREAGAN • EECI ENVIRONMENTS 42

Slide 47

Slide 47 text

ERIKREAGAN • EECI AN ENVIRONMENT IS any server running an instance of your site 43

Slide 48

Slide 48 text

ERIKREAGAN • EECI COMMON ENVIRONMENTS • Production - the public-facing “live” site • Staging - typically used for a final test • Development - shared team development • Local - each developer’s local instance 44

Slide 49

Slide 49 text

ERIKREAGAN • EECI SURVEY STATS 45

Slide 50

Slide 50 text

Devs currently using a Production Environment ERIKREAGAN • EECI 100% 46

Slide 51

Slide 51 text

Devs currently using a Staging Environment ERIKREAGAN • EECI 59% 47

Slide 52

Slide 52 text

Devs currently using a Shared Dev Environment ERIKREAGAN • EECI 32% 48

Slide 53

Slide 53 text

Devs currently using a Local Dev Environment ERIKREAGAN • EECI 77% 49

Slide 54

Slide 54 text

Devs who keep using environments post-launch ERIKREAGAN • EECI 29% 50

Slide 55

Slide 55 text

ERIKREAGAN • EECI 51 WHY DO YOU USE ENVIRONMENTS?

Slide 56

Slide 56 text

ERIKREAGAN • EECI 52 “Local development is incredibly fast and you don't have to worry about setting up crazy conditionals and memeber preferences to hide what you are working on on the live site.”

Slide 57

Slide 57 text

ERIKREAGAN • EECI 53 “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.”

Slide 58

Slide 58 text

ERIKREAGAN • EECI 54 “Automated deployments and multiple environments are essential to any agile-oriented developer. They save time, reduce errors and streamline site maintenance.”

Slide 59

Slide 59 text

ERIKREAGAN • EECI 55 GETTING SET UP What is potentially unique to each environment?

Slide 60

Slide 60 text

ERIKREAGAN • EECI GETTING SET UP • Server paths • URL root • EE upload paths • Debug mode intentions • URI support (PATH_INFO) • Cache settings 56 What’s Unique?

Slide 61

Slide 61 text

ERIKREAGAN • EECI ROBUST CONFIG FILE Saves time and adds flexibility 57

Slide 62

Slide 62 text

ERIKREAGAN • EECI GETTING SET UP ✓ Server paths ✓ URL root - EE upload paths ✓ Debug mode intentions ✓ URI support (PATH_INFO) ✓Cache settings 58 What can be changed?

Slide 63

Slide 63 text

ERIKREAGAN • EECI GETTING SET UP /config/ config.env.php config.master.php config.{ENV}.php /public_html/ /system/ /tpl/ 59 Directory and file structure

Slide 64

Slide 64 text

ERIKREAGAN • EECI GETTING SET UP 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 config.env.php sample

Slide 65

Slide 65 text

ERIKREAGAN • EECI GETTING SET UP */ $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 config.dev.php sample

Slide 66

Slide 66 text

ERIKREAGAN • EECI GETTING SET UP /** * 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 config.master.php sample

Slide 67

Slide 67 text

ERIKREAGAN • EECI GETTING SET UP /** * 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 we're not in production $env_config['template_debugging'] = (ENV_DEBUG) ? 'y' : 'n' ; /** * Set debug to '2' if we're 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 config.master.php sample

Slide 68

Slide 68 text

ERIKREAGAN • EECI GETTING SET UP /** * 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 config.master.php sample

Slide 69

Slide 69 text

ERIKREAGAN • EECI FOCUS LAB CONFIG SETUP github.com/focuslabllc/ee-master-config 65

Slide 70

Slide 70 text

ERIKREAGAN • EECI MULTI-ENVIRONMENT CHALLENGES You didn’t think it was that easy, did you? 66

Slide 71

Slide 71 text

ERIKREAGAN • EECI BACK TO THE SURVEY 67

Slide 72

Slide 72 text

100% ERIKREAGAN • EECI 68

Slide 73

Slide 73 text

100% ERIKREAGAN • EECI 68 Keeping database changes synced across environments

Slide 74

Slide 74 text

72% ERIKREAGAN • EECI 69

Slide 75

Slide 75 text

72% ERIKREAGAN • EECI 69 Maintaining custom upload directory paths

Slide 76

Slide 76 text

Devs who say the headaches are worth the trouble 100% ERIKREAGAN • EECI 70

Slide 77

Slide 77 text

ERIKREAGAN • EECI 71 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 schema

Slide 78

Slide 78 text

ERIKREAGAN • EECI 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 environments 72

Slide 79

Slide 79 text

ERIKREAGAN • EECI 73 http://expressionengine.com/forums/viewthread/196480/

Slide 80

Slide 80 text

ERIKREAGAN • EECI 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 exceptions 74

Slide 81

Slide 81 text

ERIKREAGAN • EECI 75 Schema / Structure flows up stream

Slide 82

Slide 82 text

ERIKREAGAN • EECI 76 Content flows down stream

Slide 83

Slide 83 text

ERIKREAGAN • EECI 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 clients 77

Slide 84

Slide 84 text

ERIKREAGAN • EECI ERIKREAGAN Partner Focus Lab LLC FocusLabLLC 78