There are so many ways to create your local WordPress development environment, this is one of them, and it is an opinionated one based on my preferences.
Think of it as , an out-of-the-box way to create a composer-powered WordPress project for local development.
Creating your WordPress Project:
To start a new project using this skeleton, you just need to run :
composer create-project zaherg/wordpress-project [path] [version]
[path]is the path to the installation directory, if not defined, a wordpress-project folder will be created in your current path.
[version]is the version of the project to use when installing, if not defined, the more recent stable is used, else you can use :
Note The first two numbers from the version represent WordPress version, while the last number represent the miner changes I do for the internal code like the code inside helpers file.
Or you can use a simple git clone :
git clone https://github.com/zaherg/wordpress-project
To configure database credentials and all the others settings, you need to edit
.env file and update the following information
APP_ENV= WP_DEBUG= WP_DEBUG_DISPLAY= SCRIPT_DEBUG= GRAPHQL_DEBUG= DB_NAME= DB_USER= DB_PASSWORD= DB_HOST= WP_HOME=
All environment variables has a default value, you can always consolidate the config file to check all the environment variables available and how to change them.
Once you are done editing the
.env file, you can either run the installer via your browser or via the CLI
Installation via command line
You can install WordPress and activate a few plugins automatically via the command:
- There is some default values in
wp-cli.ymlso feel free skip them from the prompt.
- you can create a specific
wp-cli.local.ymlfile at project root and overwrite the default values.
- Make sure that the url you entered in the prompt match your
WP_HOME/coreso if your
http://wordpress.test, the url you enter should be
Default user login information
user name: admin password: password
There is a small fix for wp cli which was copied from https://github.com/orgs/wp-cli/discussions/5765 and wp-cli/wp-cli#5623 (comment)
I created a small command
composer that you can use to run
wp-cli commands and not get the deprecation errors, to use this command you need to understand how
composer works, basically remember to add
-- before any parameter you want to send for example:
- To get help we run the command
composer run wp:exec -- --help
- To activate a plugin:
composer run wp:exec plugin install disable-wordpress-updates -- --activate
And so on, hopefully, soon we will not need this trick and
wp-cli will have upgraded to support