My wpdtrt-plugin repository used my wpdtrt-helpers plugin during development.
I documented the dependency by adding wpdtrt-helpers
to the Composer file:
{
"name": "dotherightthing/wpdtrt-plugin",
"description": "Base classes for a plugin, plugin shortcode, and plugin widget.",
"type": "library",
"authors": [
{
"name": "Dan Smith",
"email": "[email protected]"
}
],
"repositories": [
{
"type": "vcs",
"url": "[email protected]:dotherightthing/wpdtrt-helpers.git"
}
],
"require-dev": {
"phpunit/phpunit": "^5.7",
"phpdocumentor/phpdocumentor": "2.*",
"dotherightthing/wpdtrt-helpers": "dev-master"
},
"require": {
"php": ">=5.6.30",
"gamajo/template-loader": "^1.3.0"
},
"autoload": {
"psr-4": {
"DoTheRightThing\\WPPlugin\\": "src"
}
}
}
I required wpdtrt-plugin
in wpdtrt-blocks' Composer file:
{
"name": "dotherightthingnz/wpdtrt-blocks",
"description": "Demo plugin using wpdtrt-plugin classes",
"type": "library",
"minimum-stability": "dev",
"authors": [
{
"name": "Dan Smith",
"email": "[email protected]"
}
],
"repositories": [
{
"type": "vcs",
"url": "[email protected]:dotherightthing/wpdtrt-plugin.git"
}
],
"require-dev": {
"phpunit/phpunit": "^5.7",
"phpdocumentor/phpdocumentor": "2.*"
},
"require": {
"php": ">=5.6.30",
"dotherightthing/wpdtrt-plugin": "dev-master"
}
}
Running composer update
loaded wpdtrt-plugin
, but not wpdtrt-helpers
.
As stated in Composer VCS repository not loading dependancies, this is because:
composer install
will install dev dependencies of the primary project, and create autoloading for dev - it will never install dev dependencies of any of the packages added viarequire
orrequire-dev
, and not add their autoload-dev.
To resolve this, I copied wpdtrt-helpers
into the require-dev
object of wpdtrt-blocks
' Composer file:
{
"name": "dotherightthingnz/wpdtrt-blocks",
"description": "Demo plugin using wpdtrt-plugin classes",
"type": "library",
"minimum-stability": "dev",
"authors": [
{
"name": "Dan Smith",
"email": "[email protected]"
}
],
"repositories": [
{
"type": "vcs",
"url": "[email protected]:dotherightthing/wpdtrt-helpers.git"
},
{
"type": "vcs",
"url": "[email protected]:dotherightthing/wpdtrt-plugin.git"
}
],
"require-dev": {
"phpunit/phpunit": "^5.7",
"phpdocumentor/phpdocumentor": "2.*",
"dotherightthing/wpdtrt-helpers": "dev-master"
},
"require": {
"php": ">=5.6.30",
"dotherightthing/wpdtrt-plugin": "dev-master"
}
}