Rudiger Rudiger - 13 days ago 5
PHP Question

Custom SilverStripe Module gets installed into vendor folder

I've created a module and its in my private repo. I've created a

composer.json
file for it:

{
"name": "company/sync",
"description": "sync",
"type": "silverstripe-module",
"authors": [{
"name": "XXXX",
"email": "XXXX"
}],
"require": {
"silverstripe/framework": "~3.2",
"composer/installers": "~1.0"
},
"extra": {
"installer-name": "sync"
},
"minimum-stability": "dev"
}


And I've got my main projects
composer.json
:

{
"name": "silverstripe/installer",
"description": "The SilverStripe Framework Installer",
"repositories": [
{
"type": "package",
"package": {
"name": "company/sync",
"version": "master",
"source": {
"url": "git@xxx:xxx/sync.git",
"type": "git",
"reference": "master"
}
}
}
],
"require": {
"php": ">=5.3.3",
"silverstripe/cms": "3.3.1",
"silverstripe/framework": "3.3.1",
"silverstripe/reports": "3.3.1",
"silverstripe/siteconfig": "3.3.1",
"silverstripe-themes/simple": "3.1.*",
"company/sync": "*"
},
"require-dev": {
"phpunit/PHPUnit": "~3.7"
},
"extra": {
"branch-alias": {
"3.x-dev": "3.3.x-dev"
},
"installer-paths": {
"sync": ["company/sync"]
}
},
"config": {
"process-timeout": 600
},
"prefer-stable": true,
"minimum-stability": "dev"
}


From what I've read, is the package is marked as a
silverstripe-module
it should put it at the root of the installation. I've also tried to set it via the
extra
parameter however it is still placed at vendor/company/sync. What am I doing wrong?

Answer

I think your problem is your custom "repositories" entry. By defining a "package" entry, you're telling composer the properties of the package and it won't look up the composer.json of your repository.

So either you fully define the "package" entry by also adding "type" and other fields, or just use a "vcs" entry (which will use your composer.json from your repository). Eg.

"repositories": [
    {
        "type": "vcs",
        "url": "git@xxx:xxx/sync.git"
    }
]

In short: Use "vcs" for repositories that have their own composer.json and only use "package" if you rely on sources that don't have any composer metadata.