Controlling Exact Folder/Directory where Packages are Written by Composer for PHP

admin

Administrator
Staff member
<h1>The Background</h1>

I'm trying to use <a href="http://getcomposer.org" rel="nofollow">Composer</a> to manage dependencies for WordPress plugins. I've built several PHP libraries <em>(<a href="https://github.com/newclarity/restian/" rel="nofollow">RESTian</a> &amp; <a href="https://github.com/newclarity/sidecar/" rel="nofollow">Sidecar</a>)</em> I want to include in subdirectories for each of several plugins we are building and those PHP libraries are hosted on GitHub. The WordPress plugins are <em>(currently)</em> hosted in private BitBucket repos as they are for clients but those plugins will also get published to WordPress plugin repository when we are ready to release them.

<h1>The Problem</h1>

I want a directory structure of
Code:
/libraries/restian/
and
Code:
/libraries/sidecar/
relative to the root of the plugin. For those who know WordPress they would ultimately look like this installed:

Code:
/wp-content/plugins/my-wp-plugin/libraries/restian/
/wp-content/plugins/my-wp-plugin/libraries/sidecar/

Problem is I've only been able to get Composer to put them within a
Code:
/newclarity/
subdirectory which is more complexity than I want to add to the directory structure of the plugin <em>(
Code:
'newclarity'
is our GitHub account)</em>:

Code:
/wp-content/plugins/my-wp-plugin/libraries/newclarity/restian/
/wp-content/plugins/my-wp-plugin/libraries/newclarity/sidecar/

<h1>The Source</h1>

Here is the
Code:
composer.json
file that I am using to research and test this:

Code:
{
  "name":"mikeschinkel/my-wp-plugin",
  "description":"My WordPress Plugin",
  "type":"wordpress-plugin",
  "config":{
    "vendor-dir":"libraries/"
  },
  "require": {
    "newclarity/restian":"dev-master",
    "newclarity/sidecar":"dev-master"
  },
  "repositories":[
    {
      "type":"git",
      "url":"https://github.com/newclarity/restian.git"
    },
    {
      "type":"git",
      "url":"https://github.com/newclarity/sidecar.git"
    }
  ]
}

And here are the current
Code:
composer.json
files from the libraries hosted at GitHub:

Code:
{
  "name": "newclarity/restian",
  "description": "RESTian: A base class library to simplify building RESTful/Web API clients in PHP",
  "require": {
      "php": "&gt;=5.2.4"
  }
}

And:

Code:
{
  "name": "newclarity/sidecar",
  "description": "Sidecar: The Missing Plugin API for WordPress",
  "require":{
    "php":"&gt;=5.2.4"
  }
}

I've been researching this for over 4 hours now. Any help would be appreciated.

-Mike