Two weeks ago we had a WordCamp in Jerusalem Were i Spoke about Development Environments in WordPress ad As promised here is a short recap and the "Slides"
What's this about
- Development Environments.
- Development Workflow.
- Tips and Tricks:
- Server
- Domain
- Files
- Database
- Some (little) Version Control.
Basically i covered:
- a A workflow of 3 environments (Development , Staging and live)
Development or Local - usually refers to your local machine where you have your web server, database, IDE, and related tools installed.
Staging or Testing - is a server the resembles where the project is actually going to live and where you upload your work for testing.
Live or Production - is where the project is live on the web. - Avoiding domain name issues
- Setup wp-config.php For multiple environments
- "Jumping" between environments transferring syncing files and database
Now The second part is all about version control
On Version Control:
- Whats version control?
- Why Version control?
- Version Control Methods With WordPress:
- Control The entire WordPress environment
- Control only the WP-Content Directory
- Control only a specific Theme or Plugin
- A few Simple Commands (enough to get you started).
- Using a Remote Host as a central repository (which is what i strongly recommend when starting out)
- A typical Workflow.
The Slides
Resources
Server / Stack:
WAMP - WampServer is a web development platform on Windows.
MAMP - Install Apache, PHP and MySQL with few clicks under Mac OS X.
XAMPP - easy to install Apache for Linux, Windows, Mac OS X, and Solaris.
Bitnami - simple stack with WordPress bundled in.
Instant WordPress - The easiest and quickest way to install WordPress!
DesktopServer - Another easy way with virtual servers and deploy capability.
Plugins mentioned:
WP Migrate DB - WP Migrate DB exports your database as a MySQL data dump (much like phpMyAdmin), does a find and replace on URLs and file paths
Duplicator – “ability to migrate a site from one location to another location in 3 steps.”
Per Request
I've been asked to post and explain the wp-config.php that was mentioned , which is create a file per environment so:
on the development environment i create a file named dev-config.php
/* Development Environment */ define('WP_ENV', 'local'); define('WP_DEBUG', true); define('DB_NAME', 'local_db_name'); define('DB_USER', 'local_db_user'); define('DB_PASSWORD', 'local_db_password'); define('DB_HOST', 'local_db_host');
on the staging environment i create a file named stage-config.php
/* Staging Environment */ define('WP_ENV', 'stage'); define('WP_DEBUG', true); define('DB_NAME', 'stage _db_name'); define('DB_USER', 'stage _db_user'); define('DB_PASSWORD', 'stage _db_password'); define('DB_HOST', 'stage _db_host');
And then my wp-config.php file looks like this:
//First we check for development env if ( file_exists( dirname( __FILE__ ) . '/dev-config.php' ) ) { include( dirname( __FILE__ ) . '/dev-config.php' ); } elseif ( file_exists( dirname( __FILE__ ) . '/stage-config.php' ) ) { //then we check for staging env include( dirname( __FILE__ ) . '/stage-config.php' ); }else { //if we got here then we are at production env. define('WP_ENV', 'production'); define('WP_DEBUG', false); define( 'DB_NAME', 'production_db' ); define( 'DB_USER', 'production_user' ); define( 'DB_PASSWORD', 'production_password' ); define( 'DB_HOST', 'production_db_host' ); }
Enjoy!