This project aims to solve having to recreate your WordPress local development environment when starting a new WordPress project. This will fast forward your setup time so that you can get straight to coding.
The second goal of the project was to be able to hand off or share the Docker environment with a team. They should be able to start the Docker container and contribute to the project.
The following items should have already been installed on you system. If not, please do so now.
-
Download load the project here.
-
Run
npm install
-
Run
composer install
-
Run
docker-compose up -d
to boot up the environment.
-
WordPress Coding Standard built in
-
PHP linting to WordPress coding standards.
-
JavaScript linting to WordPress coding standards.
-
CSS linting to WordPress coding standards.
-
-
Sass compiling for a module CSS approach.
-
Hot reloading on CSS and JS edits.
-
Babel for using latest JavaScript syntax.
-
Browser-Sync to test UI accross multiple devices.
-
More features to come...
There's a command to back up the database. Docker is able to boot up and use that database to keep a persistent copy of where you left of when the database was saved. If you plan to have another developer help with the project, save the database, commit it and anyone helping should be able to pick up right where you left off.
Use npm run savedb
to get a backup of the database.
This project is configured with settings for VSCode to use recommended plugins for PHP development, including linting for the WordPress Style Guide and etc...
Please install the recommanded extension that comes with this project.
WP-CLI is available.
Because it's an npm run
command, if you need to pass flags, run npm run wp --
, for example npm run wp -- core update
.
-
.vscode
= This directory hold specific setting for the VSCode editor.-
extension.json = This file is used to suggest recommended VSCode editor extensions to install.
-
settings.json = This file is used to configure the VSCode editior setting at the project level.
-
-
docker-4wordpress-theme
= This directory is used to pull in the child theme. This is your main working folder and most of your time should be spent working here. This is where you will build your site at. -
html
= This directory hold the WordPress core source code. There shouldn't be a need to edit these files unless you want to make tweak to certain core files. -
initdb
= This directory is used to hold a database backup. If you're starting from a clean project that hasn't been initiated, the project will install this database if there's an initdb.sql in the directory. You can create a backup runningnpm run savedb
. Note This file is overwritten when a new backup is run. -
node_modules
= This directory holds your Nodejs dependencies and should just be ignore and never touched. -
vendor
= This directory holds your Composer dependencies and should just be ignore and never touched.
In the WebPack workflow you will find a src
directory. This directory is where most of your development edits will happen. I've chosen to name the compiled directory that WebPack creates to assets/
since the files/content that live there will mostly be of JavaScript, images and CSS type. Keep in mind that most WebPack projects name the compiled directory
build/
. Since this is intended for WordPress it doesn't follow WebPack normal conventions.
I decided to pass my Less through PostCss as it will allow me to write future CSS code if I wanted to opt out of Less specific coding style.
-
postcss-import -- I'm using this plugin to be able to import regular css as file aside less file too.
-
autoprefixer -- I'm using this plugin to automatically insert browsers prefixes so I don't have to think about it.
-
postcss-cssnext -- I'm using this plugin so that I'm able to use future CSS code now.
-
rimraf -- Using this to make sure I start with a new clean compilation of my assets files.
To have webpack watch and compile your assets/
files, run
npm start
Hit ctrl + 'c' to kill webpack watch command.
When you don't have shell access but you can sftp into the server.
Use rsync to deploy your files/directories to you production server.
- Setup a production build script
- Setup up image compression.
- Reformat code style