- Unit testing via PHPUnit
- Code standards evaluation via PHP_CodeSniffer
- Build tools for plugin assets via Yarn and webpack.
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Install Homebrew Cask:
brew tap caskroom/cask
brew install ansible
brew cask install virtualbox
brew cask install vagrant
vagrant plugin install vagrant-bindfs
vagrant plugin install vagrant-hostmanager
brew install composer
brew install node
brew install yarn
Create a directory for your local development environment and
mkdir ~/Code/pressbooks-dev && cd ~/Code/pressbooks-dev
Clone pressbooks/trellis into
git clone --depth=1 email@example.com:pressbooks/trellis.git && rm -rf trellis/.git
Clone pressbooks/bedrock into
git clone --depth=1 firstname.lastname@example.org:pressbooks/bedrock.git site && rm -rf site/.git
cd ~/Code/pressbooks-dev/site composer require pressbooks/pressbooks:dev-dev composer require pressbooks/pressbooks-publisher:dev-dev composer require pressbooks/pressbooks-book:dev-dev`
~/Code/pressbooks-dev/trellis/group_vars/development/wordpress_sites.yml to reflect your desired local development site URL, replacing all instances of
pressbooks.test or whatever you prefer. For example:
wordpress_sites: example.com: site_hosts: - canonical: pressbooks.dev redirects: - www.pressbooks.dev local_path: ../site # path targeting local Bedrock site directory (relative to Ansible root) admin_email: email@example.com multisite: enabled: true subdomains: false ssl: enabled: false provider: self-signed cache: enabled: false env: domain_current_site: pressbooks.dev wp_home: http://pressbooks.dev wp_siteurl: http://pressbooks.dev/wp
You can leave
example.com as is unless you plan on setting up matching staging or production environments. In that case, you will need to update all instances of
~/Code/pressbooks-dev/trellis/group_vars/ to a consistent value. If you are interested in configuring a staging or production environment, you should consult the Trellis docs as that is outside the scope of this tutorial.
Change to the
~/Code/pressbooks-dev/trellis/ directory and run
cd ~/Code/pressbooks-dev/trellis/ && vagrant up
You will be required to enter your macOS password at a certain point in the process. Fully provisioning your development environment may take up to 30 minutes.
The default Pressbooks username:password is
Acess and error logs are located on the VM in following directory:
Unit testing in the VM:
vagrant ssh cd /srv/www/example.com/current bin/install-wp-tests.sh pressbooks_tests pressbooks_test '' 127.0.0.1 latest true composer test
Coding standards in the VM:
vagrant ssh cd /srv/www/example.com/current composer standards
- At the command prompt from the Pressbooks plugin directory, e.g.
yarnto install build dependencies.
- Then, run
yarn run devor
yarn run productionto build your plugin assets (
yarn run productionwill add a version hash to the asset manifest for browser cache busting).
cd ~/Code/pressbooks-dev/site composer update pressbooks/pressbooks --with-dependencies composer update pressbooks/pressbooks-publisher --with-dependencies composer update pressbooks/pressbooks-book --with-dependencies