简体   繁体   中英

I get “Your requirements could not be resolved to an installable set of packages.” when I run composer update

I wrote a an app using laravel 5.2. This app have modules/package. all packages will be located in a folder called modules .

My first package is located in a folder called modules/Mikea/Surveys . Mikea is the vendor's name and Surveys is the module/package name. Each package has it's own composer.json file which allows me to configure each package with it's own composer configs. ( I currently have one package but I can have more later)

In my main composer.json file I am using "path" type in the repositories section like you see in the following composer.json file

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.2.*",
        "laravelcollective/html": "5.2.x-dev",
        "mikea/surveys": "*"
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~4.0",
        "phpspec/phpspec": "~2.1",
        "symfony/dom-crawler": "~3.0",
        "symfony/css-selector": " ~3.0"
    },
    "repositories": [
        {
            "type": "path",
            "url": "modules/Mikea/Surveys"
        }
    ],
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/",
            "Modules\\": "modules/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php"
        ]
    },
    "scripts": {
        "post-install-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "pre-update-cmd": [
            "php artisan clear-compiled"
        ],
        "post-update-cmd": [
            "php artisan optimize"
        ],
        "post-root-package-install": [
            "php -r \"copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ]
    },
    "config": {
        "preferred-install": "dist"
    }
}

in the second composer.json file "the package file" I have the following

{
    "name": "mikea/surveys",
    "type": "library",
    "description": "Survey System",
    "authors": [
        {
            "name": "Mike A",
            "email": "some@email.com"
        }
    ],
    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "mikea/surveys",
                "version": "0.1.0",
                "source": {
                    "type": "path",
                    "url": "modules/Mikea/Surveys"
                }
            }
        }
    ],
    "require": {
        "php": ">=5.4.0"
    },
    "autoload": {
        "classmap": [
            "database/migrations",
            "database/seeds"
        ],
        "psr-4": {
            "mikea\\Surveys\\": "src/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

when I run composer update I get the following error

F:\xampp\htdocs\proj>composer update
> php artisan clear-compiled
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested package mikea/surveys 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.

what am I doing wrong here? Why do I get this error?

I believe I figure it out.

I had to add a "version" tag in my second composer.json file like so. At least adding the "version" allowed me to run the command with no errors

{
    "name": "mikea/surveys",
    "type": "library",
    "description": "Survey System",
    "version": "0.1.0",
    "authors": [
        {
            "name": "Mike A",
            "email": "some@email.com"
        }
    ],
    "require": {
        "php": ">=5.4.0"
    },
    "autoload": {
        "classmap": [
            "database/migrations",
            "database/seeds"
        ],
        "psr-4": {
            "mikea\\Surveys\\": "src/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM