Composer
Composer Videos on 4wp.dev: Coming Soon
No Composer video yet, and here is why: a useful video, even 30–59 seconds, needs analysis, real cases, review and the right format. We're on it.
DevOps · Dependency management
One file becomes the source of truth for everything that is not your content: WordPress core, plugins from WordPress.org and your own plugins. From the classic install to Composer and Roots, on the real project 4wp.dev.
# WordPress.org plugin from WP Packages $ composer require wp-plugin/woocommerce # our plugin from GitHub, by tag $ composer add-plugin 4wp-faq # production install $ composer install --no-dev --optimize-autoloader
01 — Three approaches
The same WordPress site can be run three ways. The question is not which one is better, but where each one is allowed, where it is required, and what it costs.
composer.json / composer.lock
Composer + one project structure for every environment
vendor/ locally or in CI and upload
Bedrock needs the document root on web/; Trellis needs a server you control
02 — Evolution
Pick an era to see how plugins get into a project.
Plugins are downloaded as ZIP files and uploaded by FTP or updated in the admin, separately on every environment.
# no composer.json at all # download the plugin ZIP from wordpress.org # upload by FTP to /wp-content/plugins/ # repeat for every environment
A community mirror of WordPress.org plugins and themes as Composer packages.
wpackagist-plugin/*{
"repositories": [
{ "type": "composer", "url": "https://wpackagist.org" }
],
"require": {
"wpackagist-plugin/woocommerce": "^10.0"
}
}
The Composer repository by Roots at wp-packages.org (formerly wp-composer.com) with short names wp-plugin/* and wp-theme/*. 4wp.dev installs 11 WordPress.org plugins from it.
wp-plugin/*, wp-theme/*repo.wp-packages.org// 4wp.dev composer.json
{
"repositories": [
{ "name": "wp-packages", "type": "composer",
"url": "https://repo.wp-packages.org" }
],
"require": {
"wp-plugin/woocommerce": "^11.2.2"
}
}
03 — Two files
composer.jsonWhat you want, with version constraints: "4wpdev/4wp-faq": "^2.6".
composer.lockWhat is actually installed, with exact versions and commits. Always in Git.
vendor/, WordPress core and third-party plugins are never in Git: Composer installs them from the lock file.
04 — Where packages come from
type: wordpress-plugin with composer/installers puts a package into web/app/plugins.
wpackagist-plugin/woocommercewp-plugin/woocommerce4wpdev/4wp-faqwpackagist-theme/twentytwentyfivewp-theme/twentytwentyfive4wpdev/lms4wp05 — Roots
Roots builds open-source tools for WordPress development. 4wp.dev runs on Bedrock.
WordPress project structure built around Composer: core in web/wp, plugins and themes in web/app, configuration in .env.
A WordPress starter theme with Blade templates and a modern front-end build.
Server provisioning and deploys for WordPress, from local development to production.
4wp.dev/ ├── composer.json # what we want ├── composer.lock # what is installed ├── .env # DB, WP_ENV, WP_HOME — not in Git ├── config/ # environments └── web/ # document root ├── wp/ # WordPress core (Composer) └── app/ ├── mu-plugins/ # must-use: always on, Bedrock autoloader ├── plugins/ # wp-plugin/* and 4wpdev/* ├── themes/ └── uploads/ # content — not in Git, shared between releases
06 — Our packages
Every 4wp.dev plugin is a Composer package in its own GitHub repository. The site installs it by Git tag, so a release is a tag and a lock-file update.
11 of them are also on WordPress.org and in WP Packages as wp-plugin/4wp-*.
name — GitHub organization and slugtype — wordpress-pluginrequire — its dependenciesversion: the version is the Git tag{
"name": "4wpdev/4wp-faq",
"type": "wordpress-plugin",
"license": "GPL-2.0-or-later",
"require": {
"php": ">=7.4",
"composer/installers": "^2.0"
}
}
07 — Commands we use
composer add-plugin <slug>Connects our plugin from GitHub with the right repository entry
composer linkLocal only: replaces an installed plugin with a symlink to the working clone
composer releaseReleases our plugin and ships it to staging
composer checksQuality gate: forbidden files, secrets, PHP syntax, composer validate
composer install --no-dev --optimize-autoloaderHow production installs dependencies
08 — Migration
composer remove wpackagist-plugin/woocommerce"url": "https://repo.wp-packages.org"composer require wp-plugin/woocommerce09 — Mistakes we made
learn-gutenberg-development is ours: it is installed from GitHub, not from the plugin directory.
Some plugins were named 4wp-dev/… or forwp/… instead of the GitHub organization 4wpdev/….
Replacing a plugin’s existing file dropped its dependencies and autoload. Add to it, do not replace it.
10 — Videos
Composer
No Composer video yet, and here is why: a useful video, even 30–59 seconds, needs analysis, real cases, review and the right format. We're on it.
LMS4WP course · 7 modules
The full build log of 4wp.dev: Bedrock and Composer, own plugins as packages, Local → Staging → Production, atomic releases and deploy on push.
11 — FAQ
You should not: an update made in one environment is lost on the next deploy. Updates go through composer.json, Git and deploy, so every environment stays the same.
Yes, through a private repository or credentials in COMPOSER_AUTH.
Composer itself does: build vendor/ locally or in CI and upload the result. Bedrock also needs the document root pointed at web/.