I'd been setting up WordPress and obtaining its required plugins via composer for some years now, it works great, but I've given up trying to hack or be tricky when it comes to installing plugins that does not know how to use WP_SITEURL
and also PaaS that doesn't support non-standard WordPress folder structure.
So I am wondering if I can still use composer to setup WordPress-core (or any other package) but I want it to be installed first.
Say in your composer.json
, you have the following packages:
{
"name": "test/composer-install-order",
"type": "project",
"repositories": [
{ "type": "composer", "url": "https://wpackagist.org" }
],
"require": {
"php": ">=7.2",
"composer/installers": "~1.6.0",
"johnpbloch/wordpress": "^4.9",
"wpackagist-plugin/better-search-replace": "*",
"wpackagist-plugin/bugherd": "*",
"wpackagist-plugin/disable-emojis": "*"
},
"extra": {
"installer-paths": {
"public_html/wp-content/plugins/{$name}/": ["type:wordpress-plugin"],
"public_html/wp-content/themes/{$name}/": ["type:wordpress-theme"]
},
"wordpress-install-dir": "public_html"
},
"config": {
"preferred-install": "dist",
"optimize-autoloader": true,
"sort-packages": true
}
}
The composer.json
above says you required 3 plugins: better-search-replace, bugherd, and disable-emojis
But when you hit composer install
:
➜ temp1 composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 7 installs, 0 updates, 0 removals
- Installing composer/installers (v1.6.0): Loading from cache
- Installing johnpbloch/wordpress-core-installer (1.0.0.2): Loading from cache
- Installing wpackagist-plugin/better-search-replace (1.3.2): Loading from cache
- Installing wpackagist-plugin/bugherd (1.0.0.0): Loading from cache
- Installing johnpbloch/wordpress-core (4.9.8): Loading from cache
- Installing johnpbloch/wordpress (4.9.8): Loading from cache
- Installing wpackagist-plugin/disable-emojis (1.7.2): Loading from cache
Writing lock file
Generating optimized autoload files
➜ temp1
You'll only get 1 plugin inside wp-content/plugins
folder. The reason for this is because when you check the print above, the 2 plugins better-search-replace
and bugherd
where installed first BEFORE the Wordpress core files johnpbloch/wordpress
. So even composer
extracted those 2 plugin packages to its correct folder, the johnpbloch/wordpress
has removed them because it overwrote the wp-content/plugins
folder.
The only way for this to work is if I install johnpbloch/wordpress
first before the plugins, but I do not know if its possible since composer install via the composer.lock
content.