0
votes

I have to create a private yii2 extension on BitBucket, and install it in my projects with composer.

The SSH is set up correctly as far as I can understand, it was not at first - and I got an error "repo not found or you do not have permission" (or something of the kind).

The composer finds the composer.json, I removed it to test and I got an error message that "valid composer.json not found".

Now when i run composer update in my Git Bash it just prints "Nothing to install or update" and nothing appears in my vendor/ folder.

I have no errors to go on here, any ideas are mostly welcome!


I've set up the repo and added the following files:

composer.json

{
    "name": "ext. name",
    "type": "yii2-extension",

    "description": "My desc",

    "authors": [
        {
            "name": "Jorgen",
            "email": "[email protected]",
            "homepage": "http://www.domain.com"
        }
    ],

    "minimum-stability": "stable",
    "support": {
        "source": "bitbucket.org/companyname/yii2-extensionname"
    },

    "require": {
        "php": ">=5.4.0",
        "yiisoft/yii2": "2.0.*"
    },

    "autoload": {
        "psr-4": {
            "companyname\\extensionname\\": ""
        }
    }
}

.gitignore

vendor/**

models/Test.php

<?php

namespace companyname\extensionname\models;


class Test
{

}

And I've added the following to my Yii2 project composer.json:

"repositories": [
    {
        "type": "vcs",
        "url":  "ssh://[email protected]/companyname/yii2-extensionname",
    }
],

Update

So I figured out that if I add my repo in this format it's found and downloaded, but the autoloader-psr4.php file is not updated with my autoloading.

"repositories": [
{
    "type": "package",
    "package": {
        "name": "vendor/yii2-extension-name",
        "version": "master",
        "source": {
            "type": "git",
            "url": "[email protected]:vendor/yii2-extension-name",
            "reference": "origin/master"
        }
    }
}

When I have

"repositories": [
    {
        "type": "git",
        "url": "https://bitbucket.org/vendor/yii2-extension-name"
    }
],

I get the following error:

Problem 1 - The requested package vendor/yii2-extension-name could not be found in any version, there may be a typo in the package name.

Potential causes: - A typo in the package name - The package is not available in a stable-enough version according to your minimum-stability setting see https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion for more details.

Read https://getcomposer.org/doc/articles/troubleshooting.md for further common problems.

There is no typos, its found and downloaded when I use "package". But then the autoloader is not updated.I've also tried all sorts of variations with git@, https and ssh. It always works as a package, never as a git or vcs.

Edit: oh, and minimum-stability is set to dev while troubleshooting.

1

1 Answers

1
votes

You must use the correct name:

{
    "name": "vendor/yii2-extension-name",
    "type": "yii2-extension",

That is usually your Bitbucket username followed by the name of your repository.

That will work with your repositories Composer setting:

"repositories": [
    {
        "type": "git",
        "url": "https://bitbucket.org/vendor/yii2-extension-name"
    }
],