vccw - vagrant based wordpress development environment

56
VCCW WordPress development environment Takayuki Miyauchi 2015/05/16 at WordBench Osaka

Upload: takayuki-miyauchi

Post on 22-Jul-2015

1.917 views

Category:

Engineering


3 download

TRANSCRIPT

Page 1: VCCW - Vagrant based WordPress development environment

VCCW WordPress development environment

Takayuki Miyauchi 2015/05/16

at WordBench Osaka

Page 2: VCCW - Vagrant based WordPress development environment
Page 3: VCCW - Vagrant based WordPress development environment

Summary

Page 4: VCCW - Vagrant based WordPress development environment

Vagrant based development environment for theme and plugin developer. http://vccw.cc/

Page 5: VCCW - Vagrant based WordPress development environment

28,000+ downloads

Page 6: VCCW - Vagrant based WordPress development environment

50+ Provisions / day

Page 7: VCCW - Vagrant based WordPress development environment

18 contributors

Thanks a lot !!

Page 8: VCCW - Vagrant based WordPress development environment

326 commits

Page 9: VCCW - Vagrant based WordPress development environment

285 ★ Stars

Page 10: VCCW - Vagrant based WordPress development environment

What’s installed

Page 11: VCCW - Vagrant based WordPress development environment

• CentOS 6.5 • Subversion • Git • jq • Apache 2.2.x • MySQL 5.5.x

Page 12: VCCW - Vagrant based WordPress development environment

• PHP 5.4 • PHPUnit • Code Sniffer • Composer

Page 13: VCCW - Vagrant based WordPress development environment

• WordPress 3.5+ • WP-CLI • WordPress i18n Tools • WordPress Coding Standards for

PHP_CodeSniffer • WordPress Unit Test Framework

Page 14: VCCW - Vagrant based WordPress development environment

• Node.js • Grunt • Gulp

• Ruby • Bundler • Sass • Wordmove

Page 15: VCCW - Vagrant based WordPress development environment

How to use

Page 16: VCCW - Vagrant based WordPress development environment

1. Install VirtualBox 2. Install Vagrant 3. Install the vagrant-hostsupdater plugin. (Optional)

$ vagrant plugin install vagrant-hostsupdater 4. Download vagrant box

$ vagrant box add miya0001/vccw 5. Download the latest .zip from vccw.cc 6. change into a directory

$ cd vccw-x.x.x 7. Just run!

$ vagrant up

Page 17: VCCW - Vagrant based WordPress development environment

Customizing

Page 18: VCCW - Vagrant based WordPress development environment

vccw-x.x.x/site.ymlversion: latest lang: ja plugins: - contact-form-7 - jetpack theme: twentyfifteen

See provision/default.yml

Page 19: VCCW - Vagrant based WordPress development environment

~/.vccw/config.yml

lang: ja memory: 1024 cpus: 2

You can overwrite default

Page 20: VCCW - Vagrant based WordPress development environment

provision-post.sh#!/usr/bin/env bash

set -ex

/usr/local/bin/wp db import /vagrant/backup.sql

Page 21: VCCW - Vagrant based WordPress development environment

Wordmove deployment

Page 22: VCCW - Vagrant based WordPress development environment

• Pulls your WordPress data from server to VCCW.$ wordmove pull --all

• Pushes your WordPress data from VCCW to server. $ wordmove push --all

Page 23: VCCW - Vagrant based WordPress development environment

Staging / Production$ wordmove pull --all -e staging $ wordmove push --all -e production

Page 24: VCCW - Vagrant based WordPress development environment

WP-CLI

Page 25: VCCW - Vagrant based WordPress development environment

Creating a new plugin.

$ vagrant ssh -c "wp scaffold plugin my-plugin --activate" Success: Created /var/www/wordpress/wp-content/plugins/my-plugin Success: Created test files. Success: Plugin 'my-plugin' activated.

$ wp scaffold plugin my-plugin --activate

Page 26: VCCW - Vagrant based WordPress development environment

Creating a theme from _s.

$ vagrant ssh -c "wp scaffold _s my-theme --activate" Success: Created theme 'My-theme'. Success: Switched to 'My-theme' theme.

$ wp scaffold _s my-theme --activate

Page 27: VCCW - Vagrant based WordPress development environment

Creating a child theme.

$ vagrant ssh -c "wp scaffold child-theme my-child-theme \--parent_theme=twentyfifteen --activate" Success: Created /var/www/wordpress/wp-content/themes/my-child-theme Success: Switched to 'My-child-theme' theme.

$ wp scaffold child-theme my-child-theme \ --parent_theme=twentyfifteen --activate

Page 28: VCCW - Vagrant based WordPress development environment

Automated testing

Page 29: VCCW - Vagrant based WordPress development environment

$ vagrant ssh -c "wp scaffold plugin-tests my-plugin" Success: Created test files.

Creating a test files

Page 30: VCCW - Vagrant based WordPress development environment

$ tree www/wordpress/wp-content/plugins/my-plugin/ www/wordpress/wp-content/plugins/my-plugin/ ├── .travis.yml ├── Gruntfile.js ├── bin │   └── install-wp-tests.sh ├── my-plugin.php ├── package.json ├── phpunit.xml ├── readme.txt └── tests ├── bootstrap.php └── test-sample.php

Page 31: VCCW - Vagrant based WordPress development environment

Write the plugin tests<?php

class SampleTest extends WP_UnitTestCase { function test_sample() { $this->assertEquals( 'Hello Hanako!', do_shortcode( "[hello]Hanako[/hello]" ) ); } }

Page 32: VCCW - Vagrant based WordPress development environment

[vagrant@vccw my-plugin]$ phpunit Installing...

...

Configuration read from /var/www/wordpress/wp-content/plugins/my-plugin/phpunit.xml

.

Time: 1.73 seconds, Memory: 12.50Mb

OK (1 test, 1 assertion)

Run the plugin tests

Page 33: VCCW - Vagrant based WordPress development environment

Simple Map

https://github.com/miya0001/simple-map/blob/master/tests/test-simple-map.php

Page 34: VCCW - Vagrant based WordPress development environment

oEmbed Gist

https://github.com/miya0001/oembed-gist/blob/master/tests/test-oebmed-gist.php

Page 35: VCCW - Vagrant based WordPress development environment

CI Continuous Integration

Page 36: VCCW - Vagrant based WordPress development environment
Page 37: VCCW - Vagrant based WordPress development environment
Page 38: VCCW - Vagrant based WordPress development environment
Page 39: VCCW - Vagrant based WordPress development environment

Edit the .travis.ymlphp: - 5.3 - 5.4 - 5.5 - 5.6

env: - WP_VERSION=latest WP_MULTISITE=0 - WP_VERSION=4.1 WP_MULTISITE=0 - WP_VERSION=4.0 WP_MULTISITE=0 - WP_VERSION=3.9 WP_MULTISITE=0 - WP_VERSION=3.8 WP_MULTISITE=0

Page 40: VCCW - Vagrant based WordPress development environment

$ git push

Page 41: VCCW - Vagrant based WordPress development environment
Page 42: VCCW - Vagrant based WordPress development environment

Advanced tips

Page 43: VCCW - Vagrant based WordPress development environment

$ npm install grunt-init -g $ mkdir ~/.grunt-init $ git clone --recursive [email protected]:vccw-team/grunt-vccw.git \ ~/.grunt-init/vccw

$ mkdir myproject.dev $ grunt-init vccw $ vagrant up

grunt-init for VCCW

Setup

Provision

Page 44: VCCW - Vagrant based WordPress development environment

Running Serverspec tests

$ git clone [email protected]:vccw-team/vccw.git $ cd vccw $ bundle install --path vendor/bundle $ bundle exec rake spec

Command "wp option get blogdescription" exit_status should eq 0 stdout should eq "Hello VCCW.\n"

Finished in 13.25 seconds (files took 7.04 seconds to load) 76 examples, 0 failures

Page 45: VCCW - Vagrant based WordPress development environment

Another Vagrant for WordPress

Page 46: VCCW - Vagrant based WordPress development environment

VVVhttps://github.com/Varying-Vagrant-Vagrants/VVV

Page 47: VCCW - Vagrant based WordPress development environment

Chassis https://github.com/Chassis/Chassis

Page 48: VCCW - Vagrant based WordPress development environment

bedrock-ansible https://github.com/roots/bedrock-ansible

Page 49: VCCW - Vagrant based WordPress development environment

Mercury Vagrant (HGV) https://github.com/wpengine/hgv

Page 50: VCCW - Vagrant based WordPress development environment

vip-quickstart https://github.com/Automattic/vip-quickstart

Page 51: VCCW - Vagrant based WordPress development environment

wordpress-meta-environmenthttps://github.com/iandunn/wordpress-meta-environment

Page 52: VCCW - Vagrant based WordPress development environment

Information

Page 53: VCCW - Vagrant based WordPress development environment

AMIMOTO HHVM is available!!

Page 54: VCCW - Vagrant based WordPress development environment
Page 55: VCCW - Vagrant based WordPress development environment
Page 56: VCCW - Vagrant based WordPress development environment

Thanks!!