Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yii2 installing extension from private git server - framework not see it

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://[email protected]/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": "[email protected]"
    }
],
"require": {
    "yiisoft/yii2": "*",
    "yiisoft/yii2-bootstrap": "*"
},
"autoload": {
    "psr-4": {
        "author\\user\\": ""
    }
}

}

I'm trying to find a solution but it's a hard one.

like image 900
Joe Avatar asked Jan 11 '23 07:01

Joe


1 Answers

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:

"repositories": [
    {
        "type": "vcs",
        "url": "ssh://[email protected]/srv/git/user.git"
    }
],

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.

like image 112
Sven Avatar answered Jan 16 '23 02:01

Sven