Skip to content

Latest commit

 

History

History

wordpress-dev

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

wordpress-dev

Dockerized development environment for WordPress themes and plugins, with MariaDB, PHP 8.4, Node.js and the WordPress coding standards.

> Usage

./project.sh start      # generate the project, install the dependencies, start and install WordPress
./project.sh autoload   # regenerate the optimized Composer autoloader
./project.sh clean      # remove the containers, images, volumes and all files here, after asking (--force: without)

<name> below stands for PROJECT_NAME in project.sh: the name of the directory that contains project.sh, e.g. wordpress-dev.

Service URL Credentials
WordPress http://localhost <name> / <name>
Administration http://localhost/wp-admin <name> / <name>
phpMyAdmin http://localhost:8080 root / <name>

PORT_BASE=9000 ./project.sh start uses other ports, to run next to another environment: the site on 9000 and phpMyAdmin on 9001. docker-compose.yml keeps them, so later calls need no PORT_BASE.

On the first run (no src/ yet) ./project.sh start:

  1. creates the theme structure src/{assets/{ts,scss,fonts,img},parts,patterns,styles,templates} and tests/{ts,php}
  2. runs yarn init (and removes the README.md, .git, .editorconfig and .gitattributes it would add, if they did not exist before)
  3. writes composer.json and phpunit.xml, and installs PHP_CodeSniffer with the WordPress coding standards, PHPCompatibilityWP, VariableAnalysis, PHPUnit and PHPUnit Watcher. phpcs.xml is copied from the WPCS sample.

On later runs it runs composer install and yarn install instead. It then starts WordPress, which copies its files into this directory, and installs it with WP-CLI. The services wait for the database's health check, so no fixed delays are needed.

The tool containers (composer, node, php, phpdoc, phpunit, phpunit-watcher and wpcli) are in the tools profile: docker compose up -d does not start them, docker compose run --rm <service> does. For example:

docker compose run --rm phpunit
docker compose run --rm phpunit-watcher watch
docker compose run --rm composer exec phpcs
docker compose run --rm node yarn add -D sass
docker compose run --rm wpcli wp plugin list

PHP_VERSION in project.sh sets the PHP version of all PHP images (wordpress:php8.4-apache, wordpress:cli-php8.4, php:8.4-fpm-alpine) and of Composer's dependency resolution.

On GNU/Linux project.sh adds your user and group id to the containers in docker-compose.yml, so the files they create in this directory are owned by you.

> License

WordPress is free and open-source software licensed under the GNU General Public License, version 2 or later. The WordPress coding standards are licensed under the MIT License.