Or, Stop Being A Cowboy Coder
We'll be looking at ways to simplify everything in sync. This way, we can benefit from a local, staging and production workflow, but we want to make sure we spend as little time as possible managing it.
7. staging site
sta·ging | stey-jing
A test copy of the site, for
testing and QA of new code,
design or features
8. Make changes to a local copy,
then sync to staging / production
It's inefficient to make direct
changes to sites on the web
9. local development site
de·vel·op·ment | di-ˈve-ləp-mənt
A copy of the site for creating or
producing new features and/or
designs in a safe and portable
environment
23. WHAT CHANGED?
ACTION CHANGED
Edited theme files Files (theme)
Changed theme or plugin settings Database
Switched themes Files (theme) + Database
Publish new post Database + Uploads
24. SYNC CHANGES ONLY
Even for staging sites; no need to create
new staging site each time
Uploads don’t need to be synced as much
Take care not to overwrite user generated
content e.g. comments
26. GUIDELINES TO LIVE BY
Always. Backup. Production.
Database replacements should only go
production → staging / dev
Deploy from dev to production if possible
(avoid staging)
29. WP MIGRATE DB PRO
• Push and pull databases
• Media add-on will even sync files
• Starts at $90/yr - deliciousbrains.com
• Alternate, free fork = WP Sync DB
github.com/wp-‐sync-‐db/wp-‐sync-‐db
31. DUPLICATOR PLUGIN
• Cannot sync changes only
• Geared at technical audience
• Great free alternative
• https://wordpress.org/plugins/
duplicator/
32. BACKUPBUDDY DEPLOYMENT
• Sync changes from / to development,
staging and production
• Push and pull selected themes, plugins
and database tables
• A little iffy, not 100% reliable
• https://ithemes.com/wordpress-‐
backup-‐plugin-‐for-‐developers/
37. RSYNC + WP MIGRATE DB PRO
rsync
-‐avh
./wp-‐content/themes/
user@stagingserver.com:/path/to/wp-‐content/themes/
Transfer files from dev to staging
Then push database to staging with
WP Migrate DB Pro
38. WORDMOVE
• Ruby gem that automatically syncs local
and remote site files and DB
• “Think of it like Capistrano for
WordPress, complete with push/pull
capabilities”
• Can’t selectively push/pull DB tables
• https://github.com/welaika/wordmove
41. DON’T SYNC UPLOADS
#
~/wp-‐content/uploads/.htaccess
RewriteEngine
on
RewriteCond
%{REQUEST_FILENAME}
!-‐d
RewriteCond
%{REQUEST_FILENAME}
!-‐f
#
Production
site
lives
at
http://example.com
RewriteRule
(.*)
http://example.com/wp-‐content/uploads/$1
Load uploads from production with .htaccess
Alternatively, use the Uploads by Proxy plugin
wordpress.org/plugins/uploads-‐by-‐proxy/
42. DISABLE PLUGINS ON DEV / STAGING
if
(
defined(
'WP_LOCAL_DEV'
)
&&
WP_LOCAL_DEV
)
{
new
CWS_Disable_Plugins_When_Local_Dev(
array(
'google-‐analyticator/google-‐analyticator.php',
'vaultpress/vaultpress.php',
'w3-‐total-‐cache/w3-‐total-‐cache.php',
'wordfence/wordfence.php',
'wordpress-‐https/wordpress-‐https.php',
)
);
}
https://markjaquith.wordpress.com/
2011/06/24/wordpress-‐local-‐dev-‐tips/
43. WP LOCAL TOOLBOX
• Control your dev, staging and live
environments without touching the DB
• Can disable plugins, but needs to modify
wp-config.php file
• wordpress.org/plugins/wp-‐local-‐toolbox/