composer-managed-wordpress
composer-managed-wordpress copied to clipboard
Install and manage WordPress with Composer π¨βπ
Composer managed WordPress
You may learn how I install WordPress. Almost everything will come from Composer packages, the rest is under version control (git).
Thus the repository of a WordPress installation should barely contain files.
Support my work
Please consider sponsoring me monthly if you use my packages in an agency.
Directory structure
Most of these files are excluded from this repository as they are installed by Composer!
/: root directory with configuration files and documentsvendor/: dependencies (packages)public/: webserver's document root withindex.php,wp-config.php,favicon.icopublic/$PROJECT_NAME/: WordPress corepublic/wp-content/:wp-contentdirectory
vendor/
UPGRADE.md
composer.json
composer.lock
wp-cli.yml
public/ββ¬βindex.php (modified)
ββwp-config.php
ββPROJECT_NAME/ββ¬βindex.php
β ββwp-load.php
β ββwp-login.php
β ββwp-admin/
β ββwp-includes/
ββwp-content/
Package types
- Themes from WordPress.org's theme directory through wpackagist
- Your custom theme should be developed as a separate package in a repository of its own
- Plugins from WordPress.org's plugin directory through wpackagist
- Your custom plugins should be developed as separate packages
- Purchased plugins can be installed by
ffraenz/private-composer-installer - Must-use plugins and dropins can be installed by
koodimonni/composer-dropin-installer
All other files - except public/wp-config.php - should be kept under version control.
Usage
- Run WordPress core, plugins and theme on PHP 7.4 (as of 2023)
- Change the directory name "project" in
.gitignore,composer.json,public/index.php,wp-cli.yml - Customize
composer.jsonand create documents - Create
.envif you have purchased plugins - Add MU plugins
- Set GitHub OAuth token if you develop a private theme or plugins
composer config github-oauth.github.com "$YOUR_GITHUB_TOKEN" - Create
public/wp-config.phpincludingWP_CONTENT_DIRandWP_CONTENT_URLpointing topublic/wp-content, and loadingvendor/autoload.php - Set
WP_ENVIRONMENT_TYPEenvironment variable (in PHP-FPM configuration or inpublic/wp-config.php) - Issue
composer update --no-dev - Administer your WordPress installation with WP-CLI
wp core install --title="WP" --admin_user="myname" --admin_email="[email protected]" --admin_password="12345" wp option update home "https://example.com" wp option update siteurl "https://example.com/project"
WordPress core installation
These are possible variations.
roots/wordpress-no-content+johnpbloch/wordpress-core-installerjohnpbloch/wordpressrepositories.packagewith current ZIP file from wordpress.orgroots/wordpress
Packages provided by Roots point to wordpress.org ZIP files and git repositories.