The default type of Composer package is library
. Composer puts such packages in vendor/[vendor]/[name]
, which does not fit typical WordPress directory layout well.
However it is easy adjust it.
composer/installers
is a package of special composer-installer
type. It catches packages with non-library
types during installation and (if they match types it supports) adjusts their paths.
To make use of it your extension’s composer.json
should contain:
{
"type" : "wordpress-plugin",
"require" : {
"composer/installers" : "~1.0"
}
}
Type can also be wordpress-theme
and wordpress-muplugin
.
When used in root site stack package it would make packages go into wp-content/*
directories as WordPress things usually do.
If you don’t like defaults you can override them in root package (and there only, one of things only root one gets to decide) individually or in bulk:
{
"extra" : {
"installer-paths" : {
"content/plugins/{$name}/": ["type:wordpress-plugin"]
}
}
}
Note that this only works for packages that declare composer/installers
support. You cannot customize paths for generic library
packages. However you can customize location of vendor
directory to rename and/or move from default root location:
{
"config" : {
"vendor-dir" : "wp-content/vendor"
}
}