2
votes

i have a new project where i want to require a private Gitlab Repository. Both Repositories belong to me, so i can change whatever i want.

The composer.json of the project looks like:

{
    "name": "thisismyproject",
    "type": "project",
    "minimum-stability": "dev",
    "authors": [
        {
            "name": "me",
            "email": "[email protected]"
        }
    ],
    "repositories": [
        {
            "type": "vcs",
            "url": "https://gitlab.com/me/my-wordpress-plugin.git"
        }
    ],
    "require": {
        "composer/installers": "^1.0@dev",
        "me/my-wordpress-plugin": "dev-master"
    },
    "extra": {
        "installer-paths": {
            "wp-content/plugins/{$name}": [
                "type:wordpress-plugin"
            ]
        }
    },
    "config": {
        "gitlab-token" : {
            "gitlab.com": "thisismysupersecrettoken"
        }
    }
}

The composer.json of the wordpress plugin repository looks like:

{
    "name": "WordPress Plugin",
    "description": "lorem",
    "type": "wordpress-plugin",
    "authors": [
        {
            "name": "me",
            "email": "[email protected]"
        }
    ],
    "require": {},
    "autoload": {
        "psr-4": {
            "SomeNamespace\\": "."
        }
    },
    "extra": {
        "branch-alias": {
            "dev-master": "1.0-dev"
        }
    }
}

The output of composer update -vvv looks like:

Downloading https://gitlab.com/api/v4/projects/me%2Fmy-wordpress-plugin
Downloading https://gitlab.com/api/v4/projects/me%2Fmy-wordpress-plugin/repository/branches?per_page=100
Downloading https://gitlab.com/api/v4/projects/me%2Fmy-wordpress-plugin/repository/files/composer%2Ejson/raw?ref=14
3c1818bfc96dcaa4ee5c26cc0bd379c395491c
Downloading https://gitlab.com/api/v4/projects/me%2Fmy-wordpress-plugin/repository/tags?per_page=100
Reading composer.json of WordPress Plugin (v1.0.0)
Downloading https://gitlab.com/api/v4/projects/me%2Fmy-wordpress-plugin/repository/files/composer%2Ejson/raw?ref=14
3c1818bfc96dcaa4ee5c26cc0bd379c395491c
Writing /home/vagrant/.cache/composer/repo/gitlab.com/me/my-wordpress-plugin/143c1818bfc96dcaa4ee5c26cc0bd379c39549
1c into cache
Importing tag v1.0.0 (1.0.0.0)
Reading composer.json of WordPress Plugin (master)
Importing branch master (dev-master)
Downloading https://packagist.org/packages.json
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested package me/my-wordpress-plugin could not be found in any version, there may be a typo in the pa
ckage 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  for more details.

Read  for further common problems.

Any advice?

Thanks.

1
Have you checked for the Problem 1 and potential causes ?Himanshu Upadhyay
Any custom repositories that you use MUST be defined in the root composer.json. You have to duplicate that section from your project package to anything that wants to use it. You should also be using proper, meaningful vendor namespaces and package names, not me/mything, even for internal packages like this.Sammitch
@HimanshuUpadhyay thats the reason im asking...4lxndr
@Sammitch it is and yes, its just for the question here4lxndr
Also, I've been down the whole "private packages" rabbit-hole before, and you should probably look at using something like Satis before you erode your sanity too much more.Sammitch

1 Answers

4
votes

You are receiving the error because your package name is not the same.

To fix it, you need to update the name in the composer.json of your WordPress plugin.

{
    "name": "me/my-wordpress-plugin",
    "description": "WordPress Plugin",
    "type": "wordpress-plugin",
    "authors": [
        {
            "name": "me",
            "email": "[email protected]"
        }
    ],
    "require": {},
    "autoload": {
        "psr-4": {
            "SomeNamespace\\": "."
        }
    },
    "extra": {
        "branch-alias": {
            "dev-master": "1.0-dev"
        }
    }
}

The name should match the key in the require of your main composer.json:

"require": {
    "composer/installers": "^1.0@dev",
    "me/my-wordpress-plugin": "dev-master"
},