- PHP: Version 8.2 or higher
- Composer: Install Composer
- Node.js: Version 18.0
- Packages: Contains all project-specific code such as plugins, themes, mu-plugins, and custom libraries. These are built into the
public
directory using symlinks via Composer. - Public: Contains files used by WordPress, automatically generated from packages by Composer. This folder should not be modified manually.
- Tools: Contains build and setup scripts used by Codeship and Local.
- Config: Contains environment variable setup files.
-
Create a Git Repository:
- If setting up a new project, create a git repository using Project Base as the template.
-
Create a New Site in Local:
- Enable multisite (subdirectory) if applicable to the project.
-
Navigate to the app folder:
cd app
-
Remove the default public folder:
rm -rf public
-
Clone the project into the current folder:
git clone [email protected]:DekodeInteraktiv/{YOUR_PROJECT} .
-
Copy the environment example file:
cp .env.example .env
-
Update environment variables in the
.env
file:DB_NAME
,DB_USER
,DB_PASSWORD
,DB_HOST
WP_ENVIRONMENT_TYPE
(local, development, staging, production)WP_HOME
(e.g.,http://example.com
)WP_SITEURL
(e.g.,http://example.com/wp
)AUTH_KEY
,SECURE_AUTH_KEY
,LOGGED_IN_KEY
,NONCE_KEY
,AUTH_SALT
,SECURE_AUTH_SALT
,LOGGED_IN_SALT
,NONCE_SALT
-
Generate security keys (optional, requires wp-cli):
wp package install aaemnnosttv/wp-cli-dotenv-command wp dotenv salts regenerate
Or use the Roots WordPress Salt Generator.
-
Install Composer dependencies:
composer install
-
Install npm dependencies:
npm ci
-
Run local setup scripts (ensure
MYSQLI_DEFAULT_SOCKET
is set if needed):cd app/tools/local ./setup-main-site.sh ./activate-plugins.sh bash multisite.sh # Only for multisite setup
-
Update URLs for multisite to use HTTPS:
wp search-replace --url=http://{PROJECT}.site 'http://{PROJECT}.site' 'https://{PROJECT}.site' --recurse-objects --network --skip-columns=guid
-
Navigate to the site app folder and clone the project:
cd path/to/app git clone [email protected]:DekodeInteraktiv/{YOUR_PROJECT} .
-
Remove the default
wp-content
folder:rm -rf public/wp-content
-
Create a symlink for
wp-content
:ln -s ../{project folder}/public/content public/wp-content
-
Run local setup scripts:
cd tools/local ./setup-main-site.sh ./activate-plugins.sh bash multisite.sh # Only for multisite setup
To use wp-cli with Local, you can use the built-in site shell. For default system console access, add a wp-cli.local.yml
file to the root (app
) directory:
path: public/wp
require:
- wp-cli-local.php
Set the MYSQLI_DEFAULT_SOCKET
in the .env
file using the path from the Local Database tab.
Run the following commands in the root directory to build the project:
composer install
npm ci && npm run build
(See packages/themes/block-theme
for more details)
Project Base uses wp-scripts out of the box for building front-end/view and editor assets. wp-script will scan all block.json
files in the src/
folder to find available entries. This means that if you have a src
folder with a view.js
and a editor.js
, you also need to add a block.json
file at the same location. Have a look in the block-theme
theme for example or read up on wp-script auto discovery for Webpack entry points. For a more advanced setup, you can always customize builds by adding your own webpack.config.js
.
- Supply entry points manully to the CLI, e.g.
wp-scripts build src/view src/editor src/admin src/some-other-entry
. This will bypass 2 and 3. - Scan
src
folder for allblock.json
files. (Our default setup). This will support both theme/plugin assets (view/editor) and possible blocks inside thesrc/
folder. - Fallback to
src/index.*
file. This will only look for asrc/index.js
file.
-
Create a folder: Add a folder in
./packages
(e.g.,./packages/plugins
). -
Add a
composer.json
File (for themes, plugins, mu-plugins, and PHP dependencies):{ "name": "project/package-name", "description": "Short description of the package.", "type": "wordpress-plugin/wordpress-muplugin/wordpress-theme/other", "version": "1.0.0" }
Note: Use block-base for Gutenberg blocks.
Note: A version should always be supplied. This ensures that package versions do not change between branches, leading to unneccesary merge conflicts.
-
Add a
package.json
File (for frontend dependencies or custom React components):{ "name": "package-name", "private": true, "version": "1.0.0", "description": "Package description", "author": "Dekode", "main": "index.js", "scripts": { "build": "echo \"Error: no build specified\" && exit 1", "start": "echo \"Error: no start specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1", "clean": "rm -rf node_modules build dist" } }
-
Update Root Configuration:
- For Composer packages, add an entry under
"require"
incomposer.json
:"project/package-name": "@dev"
- For npm packages, add an entry under
"devDependencies"
inpackage.json
:"package-name": "file:packages/folder/package-name"
- For Composer packages, add an entry under
-
Install the Package:
- For Composer:
composer update
- For npm:
npm install
Re-run
npm run build
ornpm run start
if needed. - For Composer:
- PostCSS: PostCSS Documentation
- WebPack: WebPack Concepts
- WP Scripts: WP Scripts Guide