Giter Site home page Giter Site logo

wp-docker's Introduction

WP Docker (Beta)

Build Status Coverage Status

A docker environment for WordPress site development.

Requirements

  • docker-compose
  • composer
  • npm

Usage

Clone Repository:

git clone --recursive [email protected]:xwp/wp-docker.git

Install Plugins:

composer install

Add Environment Variables:

cp .env.sample .env

This creates a new .env file from the .env.sample file and is not checked into git, change the settings as needed.

Start:

bin/up {optional:parameters}

The optional parameters give you the ability to append configurations to the script. However, the bin/up script by default adds the --build parameter if nothing is passed to it. For example, you could run Docker in daemon mode by adding -d and that would be the only parameter. So if you want the default behaviour plus daemon mode you would do:

bin/up --build -d

Although it's not recommended, you can alternatively use:

docker-compose up

Stop:

bin/down

Alternatively use:

docker-compose down

MySQL

Docker will execute files with extensions .sh, .sql and .sql.gz that are found in the mysql directory. Files will be executed in alphabetical order. You can easily populate your mariadb service by mounting a SQL dump into that directory and provide custom images with contributed data. SQL files will be imported by default to the database specified by the MYSQL_DATABASE variable. However, it may not be the ideal workflow to load the DB this way so there are additional custom import and export capabilities.

Import:

bin/mysql-import {path-to-file}.sql

Running the bin/mysql-import bash script will import an SQL file into the database which is defined in the MYSQL_DATABASE environment variable. All you need to do is supply a path to the SQL file.

Export:

bin/mysql-export 

Running the bin/mysql-export bash script will create a backup of the database inside the mysql/backups directory with the format {db-name}-{timestamp}.sql

PHPUnit

bin/phpunit 

Running the default command without any parameters will automatically run the testsuite. As well, the pre-commit hook will also run the testsuite for the plugins automatically. Both use the PHPUNIT_CONFIG variable found in the .dev-lib configuration file.

The bin/phpunit bash script is a wrapper for phpunit inside Docker and excepts all the same parameters. The following will manually run the unit tests for the plugins.

bin/phpunit -c /var/www/html/wp-tests/phpunit.xml.dist 

You can additionally add a coverage clover by doing the following.

bin/phpunit -c ../wp-tests/phpunit.xml.dist --coverage-html ../wp-tests/coverage

Notice that relative paths work, as well. This is because the current working directory when running test in Docker is the host machines {project_root}/bin directory.

PHPCS

bin/phpcs {path}

Performs preset PHP Coding Standard and WordPress sniffs. The bin/phpcs bash script is a wrapper for phpcs inside Docker with the parameters already supplied. The script requires/accepts an absolute (docker) or relative (host) path to a directory or file. Configurations are automatically set by parameters in the .dev-lib file.

PHPCBF

bin/phpcbf {path}

To automatically fix as many sniff violations as possible, use the phpcbf command in place of the phpcs command. The bin/phpcbf bash script is a wrapper for phpcbf inside Docker with the parameters already supplied. The script requires/accepts an absolute (docker) or relative (host) path to a directory or file. Configurations are automatically set by parameters in the .dev-lib file.

Run Commands

bin/run {command}

The bin/run bash script is a wrapper for the following docker-compose script. This is essential to interacting with the php service and its linked services. You can quicky run commands even when the Docker container is not up.

  1. docker-compose run --rm php <command>

You could also do this manually with docker exec by doing the following.

  1. docker ps
  2. Get the ID of the PHP container
  3. docker exec -it <id> <command>

Plugin Scaffolding

Foo Bar is a built-in template plugin for scaffolding WordPress plugins. The bin/plugin bash script will copy the foo-bar plugin and make the necessary replacements via:

bin/plugin "Hello World"

This will create a plugin hello-world in the wp-content/plugins directory and will greatly speed up plugin development inside this repo.

Be sure to add your new plugin to the testsuite inside the wp-tests/phpunit.xml.dist file to ensure your PHPUnit tests are included in the pre-commit hook and bin/phpunit script. It is required that you run this script from this repositories root directory.

wp-docker's People

Contributors

valendesigns avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wp-docker's Issues

Add Starter Plugins

  • Customize Posts
  • Customize Snapshots
  • Customize Object Selector
  • Query Monitor
  • WP Redis
  • REST API?
  • S3?
  • Jetpack?
  • TBD...

Plugins should be managed via Composer which means they either need to be on packagist or if they are internal and on Github we might need to update their package.json files to be compatible.

PHPStorm Integration

We need to figure out how to use WP Docker with PHPStorm and write some directions for other engineers to get setup quickly.

The wp-content directory should be a config option.

In order to facilitate using this local development tool with setups such as VIP Go or Pantheon, the wp-content directory location should be a config option and should be allowed outside of the repo root.

Add custom foo-bar plugin

Some projects need to spin up basic plugins that are tracked inside the repo and are never going to be on .org, so they don't need all the bells and whistles of the existing wp-foo-bar plugin. For that reason I want to add a slim down version that works for this repo and will be maintained here, as well. It doesn't need anything but the PHP and Tests.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.