VCCW - Vagrant based WordPress development environment

3,782 views

Published on

Published in: Engineering

VCCW - Vagrant based WordPress development environment

  1. 1. VCCWWordPress development environment Takayuki Miyauchi 2015/05/16 at WordBench Osaka
  2. 2. Summary
  3. 3. Vagrant based development environment for theme and plugin developer. http://vccw.cc/
  4. 4. 28,000+ downloads
  5. 5. 50+ Provisions / day
  6. 6. 18 contributors Thanks a lot !!
  7. 7. 326 commits
  8. 8. 285 ★ Stars
  9. 9. What’s installed
  10. 10. • CentOS 6.5 • Subversion • Git • jq • Apache 2.2.x • MySQL 5.5.x
  11. 11. • PHP 5.4 • PHPUnit • Code Sniffer • Composer
  12. 12. • WordPress 3.5+ • WP-CLI • WordPress i18n Tools • WordPress Coding Standards for PHP_CodeSniffer • WordPress Unit Test Framework
  13. 13. • Node.js • Grunt • Gulp • Ruby • Bundler • Sass • Wordmove
  14. 14. How to use
  15. 15. 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
  16. 16. Customizing
  17. 17. vccw-x.x.x/site.yml version: latest lang: ja plugins: - contact-form-7 - jetpack theme: twentyfifteen See provision/default.yml
  18. 18. ~/.vccw/config.yml lang: ja memory: 1024 cpus: 2 You can overwrite default
  19. 19. provision-post.sh #!/usr/bin/env bash set -ex /usr/local/bin/wp db import /vagrant/backup.sql
  20. 20. Wordmove deployment
  21. 21. • Pulls your WordPress data from server to VCCW.
 $ wordmove pull --all • Pushes your WordPress data from VCCW to server.
 $ wordmove push --all
  22. 22. Staging / Production $ wordmove pull --all -e staging $ wordmove push --all -e production
  23. 23. WP-CLI
  24. 24. 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
  25. 25. 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
  26. 26. 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
  27. 27. Automated testing
  28. 28. $ vagrant ssh -c "wp scaffold plugin-tests my-plugin" Success: Created test files. Creating a test files
  29. 29. $ 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
  30. 30. Write the plugin tests <?php class SampleTest extends WP_UnitTestCase { function test_sample() { $this->assertEquals( 'Hello Hanako!', do_shortcode( "[hello]Hanako[/hello]" )
 ); } }
  31. 31. [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
  32. 32. Simple Map https://github.com/miya0001/simple-map/blob/master/tests/test-simple-map.php
  33. 33. oEmbed Gist https://github.com/miya0001/oembed-gist/blob/master/tests/test-oebmed-gist.php
  34. 34. CI Continuous Integration
  35. 35. Edit the .travis.yml php: - 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
  36. 36. $ git push
  37. 37. Advanced tips
  38. 38. $ npm install grunt-init -g $ mkdir ~/.grunt-init $ git clone --recursive git@github.com:vccw-team/grunt-vccw.git ~/.grunt-init/vccw $ mkdir myproject.dev $ grunt-init vccw $ vagrant up grunt-init for VCCW Setup Provision
  39. 39. Running Serverspec tests $ git clone git@github.com: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
  40. 40. Another Vagrant for WordPress
  41. 41. VVV
 https://github.com/Varying-Vagrant-Vagrants/VVV
  42. 42. Chassis https://github.com/Chassis/Chassis
  43. 43. bedrock-ansible https://github.com/roots/bedrock-ansible
  44. 44. Mercury Vagrant (HGV)
 https://github.com/wpengine/hgv
  45. 45. vip-quickstart https://github.com/Automattic/vip-quickstart
  46. 46. wordpress-meta-environment
 https://github.com/iandunn/wordpress-meta-environment
  47. 47. Information
  48. 48. AMIMOTO HHVM is available!!
  49. 49. Thanks!!

×