• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
WordPress Development Environments
 

WordPress Development Environments

on

  • 5,172 views

My WordCamp Jerusalem 2013 WordPress Development Environments lecture

My WordCamp Jerusalem 2013 WordPress Development Environments lecture

Statistics

Views

Total Views
5,172
Views on SlideShare
2,903
Embed Views
2,269

Actions

Likes
6
Downloads
0
Comments
0

3 Embeds 2,269

http://en.bainternet.info 1827
http://2013.jerusalem.wordcamp.org 441
https://www.google.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    WordPress Development Environments WordPress Development Environments Presentation Transcript

    • Ohad RazWordPress ConsultantWordCamp Jerusalem 2013
    • WordPress Development Environments Ohad Raz WordPress Consultant WordCamp Jerusalem 2013
    • Who Am I?• Father and husband.• Ohad Raz (aka Bainternet).• WordPress Consultant Developer and Designer• Plugin developer 18 published plugins with over 132,000 downloads.• Core Contributor as of 3.5• Moderator and Editor @ WordPress Answers And I also fight crime at night
    • Whats this about?• Development Environments.• Development Environments Workflow.• Tips and Tricks: • Server. • Domain. • Files. • Database.• Some Version Control.
    • EnvironmentsLocal / Development Staging / Testing Live / Production
    • Development Environment Development usually refers to your local machine where you have your web server, database, IDE, and related tools installed.Its where you actually develop your project.
    • Staging EnvironmentThe Staging Environment is a server theresembles where the project is actuallygoing to live and where you upload yourwork for testing.Its mostly used for testing and showingoff your work.
    • Live EnvironmentThe live environment is where theproject is live on the web with realcontent and where users actuallyinteract with your work It’s the actual site.
    • But why? All Environments: • Mistakes and accidents happen. • You want to be taken seriouslyDevelopment: Staging:• Work Faster. • Client approval.• Freedom to experiment. • Test on an environment• Test multiple versions of PHP. similar to production.• Teams can work together (with version control). Live: Because Every Site need a Home.
    • Development Environment Server WAMP MAMP XAMPP Windows Mac X any platform Apache Apache Apache MySQL MySQL MySQL PHP PHP PHP Perl
    • Development Environment ServerInstall WordPress Locally :1. Download WordPress.2. Extract the downloaded zip file.3. Create a database.4. Configure wp-config.php5. Run WordPress Setup Or do it all at once with WordPress Auto Installer This script will download the latest copy of WordPress, extract the files to the directory you named, create a new database and take you straight to where all you have to do is set you sites name, your username and pass and you have a new WordPress Installation ready to roll.
    • Domain IssueLive: domain.comDev: domain.devThis way you can use a simple Search and Replace on filesand database dump.Or use real domain name Using the hosts file.Live & Dev: domain.com # Point domain.com to your computer 127.0.0.1 domain.com Windows: C:WINDOWSsystem32driversetchosts Mac/Linux: /etc/hosts
    • Domain IssueCreate A Virtual Host <VirtualHost 127.0.0.1> DocumentRoot "C:/wamp/www/WordCamp/local" ServerName domain.dev <Directory "C:/wamp/www/WordCamp/local"> Options FollowSymLinks Indexes MultiViews AllowOverride All Order deny,allow Allow from all Allow from 127.0.0.1 </Directory> </VirtualHost> [wamp] c:wampbinapacheApacheVERSIONconfhttpd.conf [mamp] /private/etc/apache2/httpd.conf [xampp] ..apacheconfextrahttpd-vhosts.conf
    • Files SyncFTP sync Only copy changed files based on size or date FileZilla - http://filezilla-project.org/Command line Rsync - http://rsync.samba.org/ Wget - http://www.gnu.org/software/wget/ Capistrano* - http://capistranorb.com/Version control Git - http://git-scm.com/ SVN - http://subversion.apache.org/ HG - http://mercurial.selenic.com/
    • Files Sync wp-config.phpOne level above the WordPress Root Directory in all environmentsand ignored in version control.Or a separate file per each environment://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);//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);
    • Files Sync wp-config.php//First we check for development envif ( 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 ); }}…
    • Database SyncNative Export ImportIts best to import into Dev then move the database over toproduction because when you import it will download all thenew media files from production.
    • Database SyncDatabase Management tools:Export & import the database using PHPMyAdmin or alternative.Use ”add drop tables” This will delete the old tables when you import.Use the ”INSERT IGNORE INTO” MySQL command to add the new tables from dev.or the ”REPLACE” command to overwrite duplicate rows in the same table.
    • Database SyncUse A plugin:WP Migrate DBWhich takes care ofserialized dataEx: s:9:“domin.dev"Becomes:s:11:“domain.info"
    • Database SyncUse Command line via SSH: # Export a database to DBdump.sql mysqldump --add-drop-table -u USERNAME –p DATABASE_NAME> DBdump.sql # Import a database into MySQL mysql DATABASE_NAME -u USERNAME -p < DBdump.sqlRemote to local and visa-versa:# Export remote database directly to local databasessh user@site.com "mysqldump --add-drop-table -u USERNAME -pPassword DATABASE_NAME" | mysql DATABASE_NAME # Export local database directly to remote database mysqldump --add-drop-table DATABASE_NAME | ssh user@site.com "mysql -u USERNAME -pPassword DATABASE_NAME "
    • All Around SolutionsServer / Stack: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:BackupBuddy - Back up, restore and move WordPress.Duplicator – “ability to migrate a site from one location to another location in 3steps.”
    • Version ControlVersion Control - track your files over time.But Why?• Easily un-break your code.  Feel free to experiment.  No more of this:  Logo.png  Logo_final.png  Logo_last.png  Logo_last2.png• Never. Lose. Anything.  If You Ever  Lost a file  Written over a file  Made a change that broke your code
    • Version ControlSome More reasons• One canonical version.  There is a clear place to go for the primary copy of the code.• Collaboration  Track changes For teams  See what others have done  Ability to reject / avoid bad changes  Simultaneous editing  Merge• Deployment!!!
    • Version ControlMethods:• Version Control the entire WordPress environment• Version Control only the WP-Content Directory• Version Control only a specific Theme or Plugin
    • Version ControlSimple git commands:• git init - initializes a git repository  git init - initializes a git repository in current folder  git init foldername - initializes a git repository in foldername• git add – tell git to keep track.  git add . - add everything.  git add somefile.php – add somefile.php• git commit - stage files / stores a version of the current code  git commit -m "commit message“• git status - allows you to see the current state of your code.• git pull – pull updates• git push – push updates
    • Version ControlOn Local Host:• Download and Install WordPress.• Create a new repository.• Tell git to ignore wp-config.php• Add and commit changes. git init . touch .gitignore | echo wp-config.php >>.gitignore git add . git commit –m”initial WordPress Commit”
    • Version ControlRepository HostsGITHUB - web-based hosting service for software development projects that use the Git revision control system.BitBucket - web-based hosting service for projects that use either the Mercurial or Git revision control systems
    • Version ControlCreate a new BitBucket Repository
    • Version ControlCreate a new BitBucket Repository
    • Version Control On Local Host: • Add Bitbucket as remote repository • Push to Bitbucket.git remote add origin https://bitbucket.org/bainternet/some-wordpress-project.gitgit push
    • Version Control On Stage/Production: • Clone Bitbucket Repository. • Run WordPress install once.git clone https://bitbucket.org/bainternet/some-wordpress-project.git
    • Version Control Workflow: On local On Servergit pull git pullgit checkout -b dev//make some changesgit commit -m "made dev changes"git checkout mastergit merge devgit commit -m “merged dev changes"git push
    • Version ControlOn local On Servergit pullgit checkout -b feature-x git pull//make some changesgit commit -m “started feature-x "git checkout mastergit checkout -b bug-y//fix bug ygit commit -m “Fixed bug y"git checkout mastergit merge bug-ygit commit -m “merged bug y fix"git pushgit checkout feature-x//finish working on feature xgit commit -m “finished feature-x "git checkout mastergit merge devgit commit -m “merged dev changes"git push
    • Questions???
    • Thank You!