The question first so you know, while reading, what my problem is: What is the correct workflow for updating a plugin within in composer/wordpress project all managed with git?
I've a wordpress project with the following directory structure:
- root
- httpdocs
- wp-content
- plugins
- wp-config.php
- ...
- composer.json
and inside the plugins
folder:
- myplugin
- composer.json
The stripped root composer.json
looks like this:
{
[...]
"require": {
"example/myplugin": "dev-master"
},
"repositories": [
{
"type": "composer",
"url": "http://composer.example.com"
}
],
"extra": {
"installer-paths": {
"httpdocs/wp-content/plugins/{$name}": [
"example/myplugin"
]
}
}
}
And the composer.json
inside the the myplugin folder:
{
[...]
"license": "proprietary",
"require": {
[...]
},
"type": "wordpress-plugin",
"autoload": {
"classmap": [
"controllers",
"lib",
"models"
]
}
}
At example.com I installed a private static composer repository (satis). So far so good, I can install all dependencies, myplugin and the myplugin dependencies with php composer.phar install
in the root folder.
Now the (my) problems begin:
- Updating: myplugin is a composer package, not a git submodule. How can I update the package while developing and testing? With a git submodule I could simply commit and push the changes, but with the composer package I have to keep the git repository for myplugin somwhere else and update from there, correct?
- Autoloading: I moved the autoload parameter from the root
composer.json
into the myplugincomposer.json
. But now the autoloader wont work correct. I can reinstall the composer dependencies without problems, and replaced the path (before: httpdocs/.../myplugin/controllers, now: controllers)
I was searching for about 6 hours but there are no information about this (or I searched for the wrong keywords)
This only answers part of your question, but if you add the git url to your root project's composer.json as a git repository, Composer will do a clone into the plugin directory. That will allow you to commit back directly.
Example: