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 ….
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

What's hot

Developers, Be a Bada$$ with WP-CLI
Developers, Be a Bada$$ with WP-CLIDevelopers, Be a Bada$$ with WP-CLI
Developers, Be a Bada$$ with WP-CLI
WP Engine
 
WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015
Fernando Daciuk
 
wp-cli
wp-cliwp-cli
Take Command of WordPress With WP-CLI
Take Command of WordPress With WP-CLITake Command of WordPress With WP-CLI
Take Command of WordPress With WP-CLI
Diana Thompson
 
Nodejs.meetup
Nodejs.meetupNodejs.meetup
Nodejs.meetup
Vivian S. Zhang
 
Building com Phing - 7Masters PHP
Building com Phing - 7Masters PHPBuilding com Phing - 7Masters PHP
Building com Phing - 7Masters PHP
iMasters
 
Shopware PWA - a technical overview of
Shopware PWA - a technical overview ofShopware PWA - a technical overview of
Shopware PWA - a technical overview of
Sander Mangel
 
Take Command of WordPress With WP-CLI at WordCamp Long Beach
Take Command of WordPress With WP-CLI at WordCamp Long BeachTake Command of WordPress With WP-CLI at WordCamp Long Beach
Take Command of WordPress With WP-CLI at WordCamp Long Beach
Diana Thompson
 
Advanced WordPress Development Environments
Advanced WordPress Development EnvironmentsAdvanced WordPress Development Environments
Advanced WordPress Development EnvironmentsBeau Lebens
 
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other ToolsCool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
Ryan Weaver
 
Write your first WordPress plugin
Write your first WordPress pluginWrite your first WordPress plugin
Write your first WordPress pluginAnthony Montalbano
 
WordCamp Finland 2015 - WordPress Security
WordCamp Finland 2015 - WordPress SecurityWordCamp Finland 2015 - WordPress Security
WordCamp Finland 2015 - WordPress Security
Tiia Rantanen
 
Migraine Drupal - syncing your staging and live sites
Migraine Drupal - syncing your staging and live sitesMigraine Drupal - syncing your staging and live sites
Migraine Drupal - syncing your staging and live sites
drupalindia
 
Angular2 ecosystem
Angular2 ecosystemAngular2 ecosystem
Angular2 ecosystem
Kamil Lelonek
 
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
Alexander Lisachenko
 
Building web framework with Rack
Building web framework with RackBuilding web framework with Rack
Building web framework with Rack
sickill
 
JSUG - Maven by Michael Greifeneder
JSUG - Maven by Michael GreifenederJSUG - Maven by Michael Greifeneder
JSUG - Maven by Michael Greifeneder
Christoph Pickl
 
Integration Test Cucumber + Webrat + Selenium
Integration Test Cucumber + Webrat + SeleniumIntegration Test Cucumber + Webrat + Selenium
Integration Test Cucumber + Webrat + Seleniumtka
 
Mastering Grunt
Mastering GruntMastering Grunt
Mastering Grunt
Spencer Handley
 

What's hot (20)

Developers, Be a Bada$$ with WP-CLI
Developers, Be a Bada$$ with WP-CLIDevelopers, Be a Bada$$ with WP-CLI
Developers, Be a Bada$$ with WP-CLI
 
WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015
 
wp-cli
wp-cliwp-cli
wp-cli
 
WPDay Bologna 2013
WPDay Bologna 2013WPDay Bologna 2013
WPDay Bologna 2013
 
Take Command of WordPress With WP-CLI
Take Command of WordPress With WP-CLITake Command of WordPress With WP-CLI
Take Command of WordPress With WP-CLI
 
Nodejs.meetup
Nodejs.meetupNodejs.meetup
Nodejs.meetup
 
Building com Phing - 7Masters PHP
Building com Phing - 7Masters PHPBuilding com Phing - 7Masters PHP
Building com Phing - 7Masters PHP
 
Shopware PWA - a technical overview of
Shopware PWA - a technical overview ofShopware PWA - a technical overview of
Shopware PWA - a technical overview of
 
Take Command of WordPress With WP-CLI at WordCamp Long Beach
Take Command of WordPress With WP-CLI at WordCamp Long BeachTake Command of WordPress With WP-CLI at WordCamp Long Beach
Take Command of WordPress With WP-CLI at WordCamp Long Beach
 
Advanced WordPress Development Environments
Advanced WordPress Development EnvironmentsAdvanced WordPress Development Environments
Advanced WordPress Development Environments
 
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other ToolsCool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
 
Write your first WordPress plugin
Write your first WordPress pluginWrite your first WordPress plugin
Write your first WordPress plugin
 
WordCamp Finland 2015 - WordPress Security
WordCamp Finland 2015 - WordPress SecurityWordCamp Finland 2015 - WordPress Security
WordCamp Finland 2015 - WordPress Security
 
Migraine Drupal - syncing your staging and live sites
Migraine Drupal - syncing your staging and live sitesMigraine Drupal - syncing your staging and live sites
Migraine Drupal - syncing your staging and live sites
 
Angular2 ecosystem
Angular2 ecosystemAngular2 ecosystem
Angular2 ecosystem
 
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
 
Building web framework with Rack
Building web framework with RackBuilding web framework with Rack
Building web framework with Rack
 
JSUG - Maven by Michael Greifeneder
JSUG - Maven by Michael GreifenederJSUG - Maven by Michael Greifeneder
JSUG - Maven by Michael Greifeneder
 
Integration Test Cucumber + Webrat + Selenium
Integration Test Cucumber + Webrat + SeleniumIntegration Test Cucumber + Webrat + Selenium
Integration Test Cucumber + Webrat + Selenium
 
Mastering Grunt
Mastering GruntMastering Grunt
Mastering Grunt
 

Viewers also liked

Tips and tricks for using wordpress as application platform.
Tips and tricks for using wordpress as application platform.Tips and tricks for using wordpress as application platform.
Tips and tricks for using wordpress as application platform.
danwestall
 
WordPress overloading Gravityforms using hooks, filters and extending classes
WordPress overloading Gravityforms using hooks, filters and extending classes WordPress overloading Gravityforms using hooks, filters and extending classes
WordPress overloading Gravityforms using hooks, filters and extending classes
Paul Bearne
 
Using WordPress as your application stack
Using WordPress as your application stackUsing WordPress as your application stack
Using WordPress as your application stack
Paul Bearne
 
Daughter Themes
Daughter ThemesDaughter Themes
Daughter Themes
Paul Bearne
 
High Performance Web Sites - Tips for faster pages
High Performance Web Sites - Tips for faster pagesHigh Performance Web Sites - Tips for faster pages
High Performance Web Sites - Tips for faster pagesCheton Wu
 
Professional Frontend Engineering
Professional Frontend EngineeringProfessional Frontend Engineering
Professional Frontend EngineeringCheton Wu
 
Gravity Forms Hooks & Filters
Gravity Forms Hooks & FiltersGravity Forms Hooks & Filters
Gravity Forms Hooks & Filtersiamdangavin
 

Viewers also liked (7)

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

Similar to Vagrant WordCamp Hamilton

Manage WordPress with Awesome using wp cli
Manage WordPress with Awesome using wp cliManage WordPress with Awesome using wp cli
Manage WordPress with Awesome using wp cli
GetSource
 
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cli
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cliWordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cli
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cli
GetSource
 
WordPress Development Environments
WordPress Development Environments WordPress Development Environments
WordPress Development Environments
Ohad Raz
 
Vagrant introduction for Developers
Vagrant introduction for DevelopersVagrant introduction for Developers
Vagrant introduction for Developers
Antons Kranga
 
Dev ninja -> vagrant + virtualbox + chef-solo + git + ec2
Dev ninja  -> vagrant + virtualbox + chef-solo + git + ec2Dev ninja  -> vagrant + virtualbox + chef-solo + git + ec2
Dev ninja -> vagrant + virtualbox + chef-solo + git + ec2
Yros
 
Take Command of WordPress With WP-CLI
Take Command of WordPress With WP-CLITake Command of WordPress With WP-CLI
Take Command of WordPress With WP-CLI
Diana Thompson
 
Write php deploy everywhere
Write php deploy everywhereWrite php deploy everywhere
Write php deploy everywhere
Michelangelo van Dam
 
Deploying Symfony | symfony.cat
Deploying Symfony | symfony.catDeploying Symfony | symfony.cat
Deploying Symfony | symfony.cat
Pablo Godel
 
Wordpress development: A Modern Approach
Wordpress development:  A Modern ApproachWordpress development:  A Modern Approach
Wordpress development: A Modern Approach
Alessandro Fiore
 
The Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/PressThe Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/Press
Jeroen van Dijk
 
Intro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentIntro to WordPress Plugin Development
Intro to WordPress Plugin Development
Brad Williams
 
Modern tooling to assist with developing applications on FreeBSD
Modern tooling to assist with developing applications on FreeBSDModern tooling to assist with developing applications on FreeBSD
Modern tooling to assist with developing applications on FreeBSD
Sean Chittenden
 
How To Set a Vagrant Development System
How To Set a Vagrant Development SystemHow To Set a Vagrant Development System
How To Set a Vagrant Development System
Paul Bearne
 
Apache and PHP: Why httpd.conf is your new BFF!
Apache and PHP: Why httpd.conf is your new BFF!Apache and PHP: Why httpd.conf is your new BFF!
Apache and PHP: Why httpd.conf is your new BFF!
Jeff Jones
 
VCCW - Vagrant based WordPress development environment
VCCW - Vagrant based WordPress development environmentVCCW - Vagrant based WordPress development environment
VCCW - Vagrant based WordPress development environmentTakayuki Miyauchi
 
20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdevFrank Rousseau
 
Vagrant for real codemotion (moar tips! ;-))
Vagrant for real codemotion (moar tips! ;-))Vagrant for real codemotion (moar tips! ;-))
Vagrant for real codemotion (moar tips! ;-))
Michele Orselli
 
WordPress Plugin Unit Tests (FR - WordCamp Paris 2015)
WordPress Plugin Unit Tests (FR - WordCamp Paris 2015)WordPress Plugin Unit Tests (FR - WordCamp Paris 2015)
WordPress Plugin Unit Tests (FR - WordCamp Paris 2015)
Ozh
 
The Themer's Guide to WP-CLI
The Themer's Guide to WP-CLIThe Themer's Guide to WP-CLI
The Themer's Guide to WP-CLI
Edmund Turbin
 
Vagrant for real
Vagrant for realVagrant for real
Vagrant for real
Codemotion
 

Similar to Vagrant WordCamp Hamilton (20)

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

More from Paul Bearne

Childthemes ottawa-word camp-1919
Childthemes ottawa-word camp-1919Childthemes ottawa-word camp-1919
Childthemes ottawa-word camp-1919
Paul Bearne
 
WP json api
WP json apiWP json api
WP json api
Paul Bearne
 
Unit tests with vagrant
Unit tests with vagrantUnit tests with vagrant
Unit tests with vagrant
Paul Bearne
 
HirshHorn theme: how I created it
HirshHorn theme: how I created itHirshHorn theme: how I created it
HirshHorn theme: how I created it
Paul Bearne
 
WortdPress Child themes: Why and How
WortdPress Child themes: Why and HowWortdPress Child themes: Why and How
WortdPress Child themes: Why and How
Paul Bearne
 
Author Avatars List demo slides
Author Avatars List demo slidesAuthor Avatars List demo slides
Author Avatars List demo slides
Paul Bearne
 

More from Paul Bearne (6)

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

Recently uploaded

AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
Roshan Dwivedi
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
AI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website CreatorAI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website Creator
Google
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 

Recently uploaded (20)

AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
AI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website CreatorAI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website Creator
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 

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 ….
  • 14.
  • 15.
  • 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

  1. Some of smallest patches
  2. 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.
  3. Uncanny Owl are eLearning Experts that can help you and your clients provide eLearning solutions
  4. So where do you edit code
  5. SPLIT TO 3 SLIDES
  6. SPLIT TO 3 SLIDES
  7. SPLIT TO 3 SLIDES
  8. Much lighter than Vagrant more option but still early