SlideShare a Scribd company logo
Vagrant
HOW TO SET UP A VAGRANT DEVELOPMENT SYSTEM
Paul Bearne @pbearne
Freelance Sr. Full Stack WordPress Developer
Plugin author of Author Avatars List ( http://wordpress.org/plugins/author-avatars/ )
WP Site Verification tool ( http://wordpress.org/plugins/wp-site-verification-tool/ )
Core contribs In WordPress versions 3.9, 4.0 and 4.2
Real-time Publishing for WordPress
Livepress.com
eLearning Solutions Powered by WordPress
UncannyOwl.com
Where do you develop your sites?
Test PHP versions
add_action( 'init', function () {
remove_post_type_support( 'post', 'editor' );
}, 99 );
◦ Needs PHP 5.2 + : Parse error: syntax error, unexpected T_FUNCTION
$result = $this->multidimensional( &$root, $keys, true );
◦ Breaks in PHP 5.4 + : Fatal error: Call-time pass-by-reference has been removed
Why use Vagrant?
No need to have a web server installed.
You can match the configuration of production server.
Project isolation - one Vagrant setup per project.
Version isolation - more than one version of WordPress.
Works the same on PC/Mac or Linux.
Vagrant
“Vagrant is a tool for building complete
development environments. With an easy-to-
use workflow and focus on automation, Vagrant
lowers development environment setup time,
increases development/production parity, and
makes the 'works on my machine' excuse a relic
of the past.”
http://www.vagrantup.com/about.html
Host Computer
Virtualbox
Shared Folder/usr/www/site C:/user/document/code
Point Source
control Here
Point
editor / IDE
Here
Run Unit Tests
Here
Point
Web browser
Here
Telnet client / vagrant ssh
Install
Vagrant: http://downloads.vagrantup.com/
VirtualBox: https://www.virtualbox.org/
Plus a configuration file
Note: Sometimes problems with latest version VirtualBox on windows
THE BASIC COMMAND LINE
$ vagrant init precise32 http://files.vagrantup.com/precise32.box
$ vagrant up
$ vagrant destroy
Scripting
AUTOMATE THE CONFIG
Options
• varying-vagrant-vagrants (VVV) : https://github.com/Varying-Vagrant-Vagrants/VVV
• vip-quickstart : https://github.com/Automattic/vip-quickstart
• Salty-WordPress : https://github.com/humanmade/Salty-WordPress
• Mercury Vagrant (HGV) : https://github.com/wpengine/hgv
• roots/bedrock-ansible : https://github.com/roots/bedrock-ansible
• Roll your own https://puphpet.com/
• more ….
Vagrant  WordCamp Hamilton
Vagrant  WordCamp Hamilton
DEMO
JUST RUN IT
VVV bits : internal commands
 Default WP Login/password: admin/password
 Db account: wp/wp
xdebug_on/ xdebug_off (via ssh shell)
 Makepot
VVV bits : Tools
 Hosts updater
https://github.com/cogitatio/vagrant-hostsupdater
vagrant plugin install vagrant-hostsupdater
 Guest Editions
https://github.com/dotless-de/vagrant-vbguest
vagrant plugin install vagrant-vbguest
 Dashboard
https://github.com/topdown/VVV-Dashboard
VVV bits : vagrant add-ons
 VVV Site Wizard
https://github.com/aliso/vvv-site-wizard
vvv -a create -n mysite -d mysite.dev -v 3.9.1 –x
 VV Site Wizard
https://github.com/bradp/vv
New fork of VVV site wizard
 Vagrant Manager for OS X.
http://vagrantmanager.com
Config demo
THE VAGRANTFILE FROM VARYING-VAGRANT-VAGRANTS
VVV on windows problems
Dos line ends
sudo dos2unix /home/vagrant/bin/*
SVN fetch fails with DB errors
svn cleanup need to be run
Windows 8 – hosts file need to be unprotect in window defender
SVN version can be different
Use “git bash” not “cmd”
Vagrant Commands
Vagrant up
◦ Start
Vagrant Suspend / resume
◦ pause/play
Vagrant halt
◦ turn off
Vagrant destroy
◦ wipeout
Vagrant status
◦ is it up
Vagrant int
◦ create empty config file
Vagrant box
◦ manage
Lets be tidy : use a “Customfile”
config.vm.synced_folder "../hello", "/srv/www/wordpress-default/wp-content/plugins/hello", :owner => "www-data", :mount_options => [ "dmode=775", "fmode=774" ]
config.vm.synced_folder "../hello", "/srv/www/wordpress-trunk/wp-content/plugins/hello", :owner => "www-data", :mount_options => [ "dmode=775", "fmode=774" ]
config.vm.synced_folder "../hello", "/srv/www/wordpress-develop/src/wp-content/plugins/hello", :owner => "www-data", :mount_options => [ "dmode=775", "fmode=774" ]
PHPUnit
https://make.wordpress.org/core/handbook/automated-testing/
<?php
class SampleTest extends WP_UnitTestCase {
function testSample() {
// replace this with some actual testing code
$this->assertTrue( true );
}
}
PHPUnit Commands
phpunit --list-groups
phpunit –groups ******
phpunit –verbose
phpunit –filter text
Core Test demo
Vagrant ssh
$ cd /srv/www/wordpress-devolop/
phpunit --group functions.php
phpunit --group 28666
Run WordPress core unit tests
PHPUnit plugin demo
Vagrant ssh
$ cd /srv/www/wordpress-trunk/
$ wp scaffold plugin-tests hello
$ cd wp-content/plugins/hello/
$ phpunit
Add Unit tests to a plugin
class MyTestClass extends PHPUnit_Framework_TestCase {
public function setUp() {
WP_Mock::setUp();
}
public function tearDown() {
WP_Mock::tearDown();
}
}
WP_Mock::onFilter( 'the_content' )->with( 'Windows Rocks!' )->reply( 'Apple Rocks!' );
wp_mock
https://github.com/10up/wp_mock
public function test_content_filter() {
WP_Mock::onFilter( 'the_content' )->with( 'Windows Rocks!' )->reply( 'Apple Rocks!' );
$post = new stdClass;
$post->post_content = 'Windows Rocks!';
setup_postdata( $post );
$content = get_the_content();
$this->assertEquals( 'Apple Rocks!', $content );
}
wp_mock test example
https://github.com/10up/wp_mock
Vagrant ssh
$ makepot wp-plugin /srv/www/wordpress-
trunk/wp-content/plugin/hello/
$ makepot wp-theme /srv/www/wordpress-
trunk/wp-content/themes/twentyfifteen/
Makepot on VVV
Makepot demo
1. Use an IDE
2. Configure your IDE
3. Enable xdebug
4. Set breakpoint
5. Walk the code and variables
6. Fix the code
Debuging
https://wordpress.tv/2014/08/03/aaron-holbrook-introduction-to-ides-and-debugging/
Questions?
What is coming next?
Docker : www.docker.com
Slides: http://flightless.us/wcmia2015/
Not ready for windows yet 
Hire Me...
PAUL@BEARNE.COM
Slides@ http://www.slideshare.net/pbearne
Email: pbearne@gmail.com

More Related Content

PDF
WordPress mit Composer und Git verwalten
PDF
Write php deploy everywhere tek11
PPTX
Installing hadoophivederby on_centos
PDF
Beyond the WordPress 5 minute Install
PDF
Web-Performance
PDF
HTTPS + Let's Encrypt
PDF
Web development automatisation for fun and profit (Artem Daniliants)
PDF
Contributing to WordPress Core - Peter Wilson
WordPress mit Composer und Git verwalten
Write php deploy everywhere tek11
Installing hadoophivederby on_centos
Beyond the WordPress 5 minute Install
Web-Performance
HTTPS + Let's Encrypt
Web development automatisation for fun and profit (Artem Daniliants)
Contributing to WordPress Core - Peter Wilson

What's hot (19)

PDF
Developers, Be a Bada$$ with WP-CLI
PDF
WordPress Realtime - WordCamp São Paulo 2015
PDF
WPDay Bologna 2013
PPTX
Take Command of WordPress With WP-CLI
PPTX
Nodejs.meetup
PDF
Building com Phing - 7Masters PHP
PDF
Shopware PWA - a technical overview of
PPTX
Take Command of WordPress With WP-CLI at WordCamp Long Beach
KEY
Advanced WordPress Development Environments
PDF
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
PDF
Write your first WordPress plugin
PDF
WordCamp Finland 2015 - WordPress Security
PPT
Migraine Drupal - syncing your staging and live sites
PDF
Angular2 ecosystem
PDF
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
PDF
Building web framework with Rack
PDF
Integration Test Cucumber + Webrat + Selenium
 
PDF
Mastering Grunt
Developers, Be a Bada$$ with WP-CLI
WordPress Realtime - WordCamp São Paulo 2015
WPDay Bologna 2013
Take Command of WordPress With WP-CLI
Nodejs.meetup
Building com Phing - 7Masters PHP
Shopware PWA - a technical overview of
Take Command of WordPress With WP-CLI at WordCamp Long Beach
Advanced WordPress Development Environments
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
Write your first WordPress plugin
WordCamp Finland 2015 - WordPress Security
Migraine Drupal - syncing your staging and live sites
Angular2 ecosystem
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
Building web framework with Rack
Integration Test Cucumber + Webrat + Selenium
 
Mastering Grunt
Ad

Viewers also liked (7)

PDF
Tips and tricks for using wordpress as application platform.
PPTX
WordPress overloading Gravityforms using hooks, filters and extending classes
PPTX
Using WordPress as your application stack
PPTX
Daughter Themes
PDF
High Performance Web Sites - Tips for faster pages
PDF
Professional Frontend Engineering
PDF
Gravity Forms Hooks & Filters
Tips and tricks for using wordpress as application platform.
WordPress overloading Gravityforms using hooks, filters and extending classes
Using WordPress as your application stack
Daughter Themes
High Performance Web Sites - Tips for faster pages
Professional Frontend Engineering
Gravity Forms Hooks & Filters
Ad

Similar to Vagrant WordCamp Hamilton (20)

PDF
Manage WordPress with Awesome using wp cli
PDF
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cli
PPTX
WordPress Development Environments
PPTX
Vagrant introduction for Developers
PDF
Dev ninja -> vagrant + virtualbox + chef-solo + git + ec2
PPTX
Take Command of WordPress With WP-CLI
KEY
Write php deploy everywhere
PDF
Deploying Symfony | symfony.cat
PDF
Wordpress development: A Modern Approach
PDF
The Enterprise Wor/d/thy/Press
PDF
Intro to WordPress Plugin Development
PDF
Modern tooling to assist with developing applications on FreeBSD
PPTX
How To Set a Vagrant Development System
PDF
Apache and PHP: Why httpd.conf is your new BFF!
PDF
VCCW - Vagrant based WordPress development environment
PDF
20130528 solution linux_frousseau_nopain_webdev
PDF
Vagrant for real codemotion (moar tips! ;-))
PDF
WordPress Plugin Unit Tests (FR - WordCamp Paris 2015)
PDF
The Themer's Guide to WP-CLI
PDF
Vagrant for real
Manage WordPress with Awesome using wp cli
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cli
WordPress Development Environments
Vagrant introduction for Developers
Dev ninja -> vagrant + virtualbox + chef-solo + git + ec2
Take Command of WordPress With WP-CLI
Write php deploy everywhere
Deploying Symfony | symfony.cat
Wordpress development: A Modern Approach
The Enterprise Wor/d/thy/Press
Intro to WordPress Plugin Development
Modern tooling to assist with developing applications on FreeBSD
How To Set a Vagrant Development System
Apache and PHP: Why httpd.conf is your new BFF!
VCCW - Vagrant based WordPress development environment
20130528 solution linux_frousseau_nopain_webdev
Vagrant for real codemotion (moar tips! ;-))
WordPress Plugin Unit Tests (FR - WordCamp Paris 2015)
The Themer's Guide to WP-CLI
Vagrant for real

More from Paul Bearne (6)

PPTX
Childthemes ottawa-word camp-1919
PPTX
WP json api
PPTX
Unit tests with vagrant
PPTX
HirshHorn theme: how I created it
PPTX
WortdPress Child themes: Why and How
PPT
Author Avatars List demo slides
Childthemes ottawa-word camp-1919
WP json api
Unit tests with vagrant
HirshHorn theme: how I created it
WortdPress Child themes: Why and How
Author Avatars List demo slides

Recently uploaded (20)

PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPTX
history of c programming in notes for students .pptx
PDF
System and Network Administration Chapter 2
PPTX
Transform Your Business with a Software ERP System
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
AI in Product Development-omnex systems
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
System and Network Administraation Chapter 3
PDF
top salesforce developer skills in 2025.pdf
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Nekopoi APK 2025 free lastest update
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Odoo POS Development Services by CandidRoot Solutions
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
history of c programming in notes for students .pptx
System and Network Administration Chapter 2
Transform Your Business with a Software ERP System
How to Migrate SBCGlobal Email to Yahoo Easily
AI in Product Development-omnex systems
Odoo Companies in India – Driving Business Transformation.pdf
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
VVF-Customer-Presentation2025-Ver1.9.pptx
System and Network Administraation Chapter 3
top salesforce developer skills in 2025.pdf
Navsoft: AI-Powered Business Solutions & Custom Software Development
ManageIQ - Sprint 268 Review - Slide Deck
Design an Analysis of Algorithms II-SECS-1021-03
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Nekopoi APK 2025 free lastest update
Internet Downloader Manager (IDM) Crack 6.42 Build 41
2025 Textile ERP Trends: SAP, Odoo & Oracle
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)

Vagrant WordCamp Hamilton

  • 1. Vagrant HOW TO SET UP A VAGRANT DEVELOPMENT SYSTEM
  • 2. Paul Bearne @pbearne Freelance Sr. Full Stack WordPress Developer Plugin author of Author Avatars List ( http://wordpress.org/plugins/author-avatars/ ) WP Site Verification tool ( http://wordpress.org/plugins/wp-site-verification-tool/ ) Core contribs In WordPress versions 3.9, 4.0 and 4.2
  • 3. Real-time Publishing for WordPress Livepress.com
  • 4. eLearning Solutions Powered by WordPress UncannyOwl.com
  • 5. Where do you develop your sites?
  • 6. Test PHP versions add_action( 'init', function () { remove_post_type_support( 'post', 'editor' ); }, 99 ); ◦ Needs PHP 5.2 + : Parse error: syntax error, unexpected T_FUNCTION $result = $this->multidimensional( &$root, $keys, true ); ◦ Breaks in PHP 5.4 + : Fatal error: Call-time pass-by-reference has been removed
  • 7. Why use Vagrant? No need to have a web server installed. You can match the configuration of production server. Project isolation - one Vagrant setup per project. Version isolation - more than one version of WordPress. Works the same on PC/Mac or Linux.
  • 8. Vagrant “Vagrant is a tool for building complete development environments. With an easy-to- use workflow and focus on automation, Vagrant lowers development environment setup time, increases development/production parity, and makes the 'works on my machine' excuse a relic of the past.” http://www.vagrantup.com/about.html
  • 9. Host Computer Virtualbox Shared Folder/usr/www/site C:/user/document/code Point Source control Here Point editor / IDE Here Run Unit Tests Here Point Web browser Here Telnet client / vagrant ssh
  • 10. Install Vagrant: http://downloads.vagrantup.com/ VirtualBox: https://www.virtualbox.org/ Plus a configuration file Note: Sometimes problems with latest version VirtualBox on windows
  • 11. THE BASIC COMMAND LINE $ vagrant init precise32 http://files.vagrantup.com/precise32.box $ vagrant up $ vagrant destroy
  • 13. Options • varying-vagrant-vagrants (VVV) : https://github.com/Varying-Vagrant-Vagrants/VVV • vip-quickstart : https://github.com/Automattic/vip-quickstart • Salty-WordPress : https://github.com/humanmade/Salty-WordPress • Mercury Vagrant (HGV) : https://github.com/wpengine/hgv • roots/bedrock-ansible : https://github.com/roots/bedrock-ansible • Roll your own https://puphpet.com/ • more ….
  • 17. VVV bits : internal commands  Default WP Login/password: admin/password  Db account: wp/wp xdebug_on/ xdebug_off (via ssh shell)  Makepot
  • 18. VVV bits : Tools  Hosts updater https://github.com/cogitatio/vagrant-hostsupdater vagrant plugin install vagrant-hostsupdater  Guest Editions https://github.com/dotless-de/vagrant-vbguest vagrant plugin install vagrant-vbguest  Dashboard https://github.com/topdown/VVV-Dashboard
  • 19. VVV bits : vagrant add-ons  VVV Site Wizard https://github.com/aliso/vvv-site-wizard vvv -a create -n mysite -d mysite.dev -v 3.9.1 –x  VV Site Wizard https://github.com/bradp/vv New fork of VVV site wizard  Vagrant Manager for OS X. http://vagrantmanager.com
  • 20. Config demo THE VAGRANTFILE FROM VARYING-VAGRANT-VAGRANTS
  • 21. VVV on windows problems Dos line ends sudo dos2unix /home/vagrant/bin/* SVN fetch fails with DB errors svn cleanup need to be run Windows 8 – hosts file need to be unprotect in window defender SVN version can be different Use “git bash” not “cmd”
  • 22. Vagrant Commands Vagrant up ◦ Start Vagrant Suspend / resume ◦ pause/play Vagrant halt ◦ turn off Vagrant destroy ◦ wipeout Vagrant status ◦ is it up Vagrant int ◦ create empty config file Vagrant box ◦ manage
  • 23. Lets be tidy : use a “Customfile” config.vm.synced_folder "../hello", "/srv/www/wordpress-default/wp-content/plugins/hello", :owner => "www-data", :mount_options => [ "dmode=775", "fmode=774" ] config.vm.synced_folder "../hello", "/srv/www/wordpress-trunk/wp-content/plugins/hello", :owner => "www-data", :mount_options => [ "dmode=775", "fmode=774" ] config.vm.synced_folder "../hello", "/srv/www/wordpress-develop/src/wp-content/plugins/hello", :owner => "www-data", :mount_options => [ "dmode=775", "fmode=774" ]
  • 25. https://make.wordpress.org/core/handbook/automated-testing/ <?php class SampleTest extends WP_UnitTestCase { function testSample() { // replace this with some actual testing code $this->assertTrue( true ); } }
  • 26. PHPUnit Commands phpunit --list-groups phpunit –groups ****** phpunit –verbose phpunit –filter text
  • 28. Vagrant ssh $ cd /srv/www/wordpress-devolop/ phpunit --group functions.php phpunit --group 28666 Run WordPress core unit tests
  • 30. Vagrant ssh $ cd /srv/www/wordpress-trunk/ $ wp scaffold plugin-tests hello $ cd wp-content/plugins/hello/ $ phpunit Add Unit tests to a plugin
  • 31. class MyTestClass extends PHPUnit_Framework_TestCase { public function setUp() { WP_Mock::setUp(); } public function tearDown() { WP_Mock::tearDown(); } } WP_Mock::onFilter( 'the_content' )->with( 'Windows Rocks!' )->reply( 'Apple Rocks!' ); wp_mock https://github.com/10up/wp_mock
  • 32. public function test_content_filter() { WP_Mock::onFilter( 'the_content' )->with( 'Windows Rocks!' )->reply( 'Apple Rocks!' ); $post = new stdClass; $post->post_content = 'Windows Rocks!'; setup_postdata( $post ); $content = get_the_content(); $this->assertEquals( 'Apple Rocks!', $content ); } wp_mock test example https://github.com/10up/wp_mock
  • 33. Vagrant ssh $ makepot wp-plugin /srv/www/wordpress- trunk/wp-content/plugin/hello/ $ makepot wp-theme /srv/www/wordpress- trunk/wp-content/themes/twentyfifteen/ Makepot on VVV
  • 35. 1. Use an IDE 2. Configure your IDE 3. Enable xdebug 4. Set breakpoint 5. Walk the code and variables 6. Fix the code Debuging https://wordpress.tv/2014/08/03/aaron-holbrook-introduction-to-ides-and-debugging/
  • 37. What is coming next? Docker : www.docker.com Slides: http://flightless.us/wcmia2015/ Not ready for windows yet 

Editor's Notes

  • #3: Some of smallest patches
  • #4: I am freelance so I need clients that will pay me to allow me to talk at WordCamp. These are 2 clients that I help with their hard problems that you may find useful LivePress is real time microblogging that is native on WordPress. And is available as part of WordPress.com VIP platform.
  • #5: Uncanny Owl are eLearning Experts that can help you and your clients provide eLearning solutions
  • #6: So where do you edit code
  • #18: SPLIT TO 3 SLIDES
  • #19: SPLIT TO 3 SLIDES
  • #20: SPLIT TO 3 SLIDES
  • #38: Much lighter than Vagrant more option but still early