I've created my yii2 extension. I keep it on my private git server. I managed the extension to be downloaded through composer using following code:
"repositories": [
{
"type": "package",
"package": {
"name": "author/yii2-user",
"version": "dev-master",
"source": {
"url": "ssh://git@my.server.pl/srv/git/user.git",
"type": "git",
"reference": "origin/master"
}
}
}
],
and "author/yii2-user": "*",
in require
section.
It all works fine but there is one problem. After downloading extension, composer should add it to the yiisoft\extension.php
file but it's not being added.
In my extension I have composer.json file like this:
{
"name": "author/yii2-user",
"description": "Auth and user manager for our apps",
"keywords": ["yii", "admin", "auth"],
"type": "yii2-extension",
"support": {
"issues": "",
"source": ""
},
"authors": [
{
"name": "j2",
"email": "j2@j2.j2"
}
],
"require": {
"yiisoft/yii2": "*",
"yiisoft/yii2-bootstrap": "*"
},
"autoload": {
"psr-4": {
"author\\user\\": ""
}
}
}
I'm trying to find a solution but it's a hard one.
Don't use the
"type": "package"
repository if you have the source code under your own control. Every info you have to add there can be figured out by Composer itself if you use the"type": "vcs"
repository and give the URL of the source code server.The correct way would be:
The Composer scans this repository for a
composer.json
, parses it and then knows all the metadata like name, type (probably important if you want to install it as a yii extension), version or branch etc.The package type does only exist to allow anybody who needs one particular software which is not maintained anymore and therefore a missing
composer.json
will never be added and/or registration at packagist.org will never be happening to substitute this lack of information. Don't use it for your own software, ever.