vccw - vagrant based wordpress development environment
TRANSCRIPT
VCCW WordPress development environment
Takayuki Miyauchi 2015/05/16
at WordBench Osaka
Summary
Vagrant based development environment for theme and plugin developer. http://vccw.cc/
28,000+ downloads
50+ Provisions / day
18 contributors
Thanks a lot !!
326 commits
285 ★ Stars
What’s installed
• CentOS 6.5 • Subversion • Git • jq • Apache 2.2.x • MySQL 5.5.x
• PHP 5.4 • PHPUnit • Code Sniffer • Composer
• WordPress 3.5+ • WP-CLI • WordPress i18n Tools • WordPress Coding Standards for
PHP_CodeSniffer • WordPress Unit Test Framework
• Node.js • Grunt • Gulp
• Ruby • Bundler • Sass • Wordmove
How to use
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
Customizing
vccw-x.x.x/site.ymlversion: latest lang: ja plugins: - contact-form-7 - jetpack theme: twentyfifteen
See provision/default.yml
~/.vccw/config.yml
lang: ja memory: 1024 cpus: 2
You can overwrite default
provision-post.sh#!/usr/bin/env bash
set -ex
/usr/local/bin/wp db import /vagrant/backup.sql
Wordmove deployment
• Pulls your WordPress data from server to VCCW.$ wordmove pull --all
• Pushes your WordPress data from VCCW to server. $ wordmove push --all
Staging / Production$ wordmove pull --all -e staging $ wordmove push --all -e production
WP-CLI
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
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
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
Automated testing
$ vagrant ssh -c "wp scaffold plugin-tests my-plugin" Success: Created test files.
Creating a test files
$ 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
Write the plugin tests<?php
class SampleTest extends WP_UnitTestCase { function test_sample() { $this->assertEquals( 'Hello Hanako!', do_shortcode( "[hello]Hanako[/hello]" ) ); } }
[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
Simple Map
https://github.com/miya0001/simple-map/blob/master/tests/test-simple-map.php
oEmbed Gist
https://github.com/miya0001/oembed-gist/blob/master/tests/test-oebmed-gist.php
CI Continuous Integration
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
$ git push
Advanced tips
$ 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
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
Another Vagrant for WordPress
VVVhttps://github.com/Varying-Vagrant-Vagrants/VVV
Chassis https://github.com/Chassis/Chassis
bedrock-ansible https://github.com/roots/bedrock-ansible
Mercury Vagrant (HGV) https://github.com/wpengine/hgv
vip-quickstart https://github.com/Automattic/vip-quickstart
wordpress-meta-environmenthttps://github.com/iandunn/wordpress-meta-environment
Information
AMIMOTO HHVM is available!!
Thanks!!