Hello,
I'm encountering different behaviors with composer install and composer update regarding wordpress themes and plugins.
I want to import custom themes and plugins into wordpress, so I added them through the composer path directive.
I'm not fully sure if this is a composer issue, an issue with your great project, or just me not doing things properly.
Here's the folder structure:
.
└── custom
├── plugins
│ └── my_custom_plugin
└── themes
└── my_custom_theme
Both my custom theme and plugin use a composer.json that has the following structure:
{
"name": "me/my_custom_plugin",
"description": "Custom Plugin",
"version": "1.0",
"type": "wordpress-plugin",
"require": {
"composer/installers": "~1.0"
}
}
However the files are only copied into wordpress/wp-content/themes (or /plugins) when I run composer update or composer install with no composer.lock file present.
This behavior can be reproduced locally.
Here's what I noticed:
- When I delete the
composer.lock file + wordpress folder + vendor folder and run composer install, it works as expected, my plugin and theme are installed.
- If I now keep the
composer.lock file that I’ve got in step 1., delete wordpress folder and vendor folder and run composer install again, my plugins and themes are NOT installed (despite the logs saying otherwise).
If I do a diff of the composer.lock files of the lock files generated in step 1 and in step 2 there is absolutely no difference between them (besides the hash).
What brings me to the conclusion that somehow the
"extra": {
"installer-paths": {
**commands seem to be ignored.
Is this a known issue? Or expected behavior?**
Here's my main composer.json file
{
"name": "johnpbloch/wordpress",
"description": "WordPress is open source software you can use to create a beautiful website, blog, or app.",
"keywords": [
"wordpress",
"blog",
"cms"
],
"type": "package",
"homepage": "http://wordpress.org/",
"license": "GPL-2.0+",
"authors": [
{
"name": "WordPress Community",
"homepage": "http://wordpress.org/about/"
}
],
"support": {
"issues": "http://core.trac.wordpress.org/",
"forum": "http://wordpress.org/support/",
"wiki": "http://codex.wordpress.org/",
"irc": "irc://irc.freenode.net/wordpress",
"source": "http://core.trac.wordpress.org/browser"
},
"require": {
"php": ">=5.6.20",
"johnpbloch/wordpress-core-installer": "^1.0 || ^2.0",
"johnpbloch/wordpress-core": "5.4.2",
"wpackagist-plugin/bootstrap-shortcodes": "^3.4",
"wpackagist-plugin/akismet": "^4.1",
"me/my_custom_plugin": "^1.0",
"me/my_custom_theme": "^1.0"
},
"repositories":[
{
"type":"composer",
"url":"https://wpackagist.org"
},
{
"type": "path",
"url": "custom/themes/*",
"options": {
"symlink": false
}
},
{
"type": "path",
"url": "custom/plugins/*",
"options": {
"symlink": false
}
}
],
"scripts": {
"copywpconfig": [
"cp wp-config.php wordpress/"
],
"post-install-cmd": "@copywpconfig"
},
"extra": {
"installer-paths": {
"wordpress/wp-content/plugins/{$name}": [
"type:wordpress-plugin"
],
"wordpress/wp-content/themes/{$name}": [
"type:wordpress-theme"
],
"wordpress/wp-content/mu-plugins/{$name}": [
"type:wordpress-muplugin"
]
}
}
}
Here's an example (with a present lock file):
➜ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Package operations: 25 installs, 0 updates, 0 removals
- Installing composer/installers (v1.9.0): Loading from cache
- Installing johnpbloch/wordpress-core-installer (2.0.0): Loading from cache
- Installing me/my_custom_plugin (1.0): Mirroring from custom/plugins/my_custom_plugin
- Installing me/my_custom_theme (1.0): Mirroring from custom/themes/my_custom_theme
...
Generating autoload files
1 package you are using is looking for funding.
Use the `composer fund` command to find out more!
> cp wp-config.php wordpress/
But when I check if the theme is present:
ls -la wordpress/wp-content/themes
.rw-r--r-- 28 trolologuy 11 Jun 0:05 index.php
drwxr-xr-x - trolologuy 11 Jun 0:05 twentynineteen
drwxr-xr-x - trolologuy 11 Jun 0:05 twentyseventeen
drwxr-xr-x - trolologuy 11 Jun 0:05 twentytwenty
Hello,
I'm encountering different behaviors with
composer installandcomposer updateregarding wordpress themes and plugins.I want to import custom themes and plugins into wordpress, so I added them through the composer path directive.
I'm not fully sure if this is a composer issue, an issue with your great project, or just me not doing things properly.
Here's the folder structure:
Both my custom theme and plugin use a
composer.jsonthat has the following structure:However the files are only copied into
wordpress/wp-content/themes(or/plugins) when I runcomposer updateorcomposer installwith nocomposer.lockfile present.This behavior can be reproduced locally.
Here's what I noticed:
composer.lockfile +wordpressfolder +vendorfolder and runcomposer install, it works as expected, my plugin and theme are installed.composer.lockfile that I’ve got in step 1., deletewordpressfolder andvendorfolder and runcomposer installagain, my plugins and themes are NOT installed (despite the logs saying otherwise).If I do a diff of the
composer.lockfiles of the lock files generated in step 1 and in step 2 there is absolutely no difference between them (besides the hash).What brings me to the conclusion that somehow the
**commands seem to be ignored.
Is this a known issue? Or expected behavior?**
Here's my main
composer.jsonfileHere's an example (with a present lock file):
But when I check if the theme is present: