locomotivemtl / wordpress-boilerplate
A modern WordPress project boilerplate.
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 14
Watchers: 15
Forks: 10
Open Issues: 3
Type:project
Requires
- php: >=7.4
- composer/installers: ^1.0 || ^2.0
- cweagans/composer-patches: ^1.7
- junaidbhura/advanced-custom-fields-pro: *
- junaidbhura/composer-wp-pro-plugins: ^1.4
- locomotivemtl/wp-lib-cms: ^1.0@dev
- locomotivemtl/wp-lib-theme: ^1.0@dev
- oscarotero/env: ^2.1
- roots/bedrock-autoloader: ^1.0
- roots/bedrock-disallow-indexing: ^2.0
- roots/wordpress: ^6.3.0
- roots/wp-config: ^1.0.0
- roots/wp-password-bcrypt: ^1.1.0
- twig/html-extra: ^3.4
- vlucas/phpdotenv: ^5.5
- wikimedia/composer-merge-plugin: ^2.0
- wpackagist-plugin/aryo-activity-log: ^2.8
- wpackagist-plugin/classic-editor: ^1.6
- wpackagist-plugin/redirection: ^5.3
Requires (Dev)
- roave/security-advisories: dev-latest
- wp-jazz/coding-standards: ^1
This package is auto-updated.
Last update: 2024-10-23 15:56:21 UTC
README
A quick and opinionated WordPress boilerplate with Composer, an easier configuration, and an improved folder structure.
This boilerplate is based on wp-jazz/wp-project-skeleton which is derived from Bedrock.
If you have the capability, please consider sponsoring Roots.
Overview
This boilerplate assumes you are familiar with wp-jazz/wp-project-skeleton and Bedrock.
Differences with wp-jazz/wp-project-skeleton:
- The Web root directory is
www
instead ofpublic
. - Includes a copy of
wp-ajax.php
, a near-identical copy of WordPress'admin-ajax.php
. - Prepared for integration with:
- Activity Log — Plugin to monitor and log all changes and activities.
- Advanced Custom Fields Pro — Plugin to allow adding extra content fields.
- Ecocide — Library to disable basic features of WordPress.
- Gravity Forms — Plugin to allow building custom forms.
- Polylang Pro — Plugin to support multilingual content.
- Includes copies of WordPress databases:
- Unilingual (English)
- Multilingual (English and French)
Requirements
- PHP >= 7.4
- Composer (Installation)
- Active licenses for Advanced Custom Fields Pro, Gravity Forms, and Polylang Pro.
Installation
-
Create a new project:
composer create-project locomotivemtl/wordpress-boilerplate
Note that installation of Composer dependencies will fail because of the premium WordPress plugins that require license keys to be defined.
Alternatively, clone the repository:
git clone https://github.com/locomotivemtl/wordpress-boilerplate.git . rm -rf .git git init git add -A git commit -m "Initial commit"
Or add the repository as a remote:
git remote add boilerplate https://github.com/locomotivemtl/wordpress-boilerplate.git git fetch boilerplate main git merge boilerplate/main
-
Update environment variables in the
.env
file.Wrap values that may contain non-alphanumeric characters with quotes, or they may be incorrectly parsed.
- Database variables:
DB_NAME
— Database nameDB_USER
— Database userDB_PASSWORD
— Database passwordDB_HOST
— Database host- Optionally, you can define
DATABASE_URL
for using a DSN instead of using the variables above (e.g.mysql://user:password@127.0.0.1:3306/db_name
)
WP_DEVELOPMENT_MODE
— Set the development mode (all
for development or empty string for production)WP_ENVIRONMENT_TYPE
— Set to environment (development
,staging
,production
)WP_HOME
— Full URL to WordPress home (https://example.com)WP_SITEURL
— Avoid editing this variable. Full URL to WordPress including subdirectory (https://example.com/wordpress)ACF_PRO_KEY
,GRAVITY_FORMS_KEY
,POLYLANG_PRO_KEY
— Premium plugin license keys.AUTH_KEY
,SECURE_AUTH_KEY
,LOGGED_IN_KEY
,NONCE_KEY
,AUTH_SALT
,SECURE_AUTH_SALT
,LOGGED_IN_SALT
,NONCE_SALT
- Generate with wp-cli-dotenv-command
- Generate with our WordPress salts generator
- Database variables:
-
Supply Composer with credentials for authenticating the installation of Polylang Pro:
This step is necessary because Polylang Pro uses Easy Digital Downloads (EDD) for distribution.
composer config [--global] --editor --auth
{ "http-basic": { "polylang.pro": { "username": "username", "password": "password" } } }
-
Add plugin(s) in
www/plugins
andwww/mu-plugins
, and theme(s) inwww/themes
either:- as you would for a normal WordPress site (add an exception to the
.gitignore
if you want to index them) - or as Composer dependencies.
- as you would for a normal WordPress site (add an exception to the
-
Most projects use pretty permalinks. This requires a
.htaccess
file on Apache servers. This file is not indexed in Git since it can contain environment-specific requirements. To create or update the file (and update rewrite rules in the database):wp rewrite flush --hard
-
Set the document root on your Web server to Jazz's
www
folder:/path/to/site/www/
. -
Access WordPress admin at
https://example.com/wordpress/wp-admin/
.
If you choose to use one of the starting databases, you will need to change the following:
- Replace the base URI:
example.test
- Add your license keys:
acf_pro_license
rg_gforms_key
rg_gforms_captcha_public_key
rg_gforms_captcha_private_key
Contributing
Contributions are welcome from everyone. We have contributing guidelines to help you get started.
Acknowledgements
This boilerplate is based on the solid work of many that have come before me, including: