[Invalidargumentexception]在composer需要时找不到包错误 [英] [Invalidargumentexception] could not find package error while composer require

查看:562
本文介绍了[Invalidargumentexception]在composer需要时找不到包错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我正试着在Packagist上制作自己的包。我已成功制作了一个项目,并通过此链接上传到GitHub GitHub - hitswa / composer-package-test:我只是在尝试创建作曲家包 [ ^ ]



这样做之后我成功地在Packagist上制作了一个项目 hiteshrohilla / common - Packagist [ ^ ]但当我尝试使用composer获取它时它给了我以下错误



Recently I was trying my hands to make my own package on Packagist. I have successfully made a project and uploaded it to GitHub on this link GitHub - hitswa/composer-package-test: I am just trying to create a composer package[^]

After doing so I successfully made project on Packagist hiteshrohilla/common - Packagist[^] but when I try to fetch it using composer it gives me the following error

composer requir hiteshrohilla/common


  [InvalidArgumentException]
  Could not find package hiteshrohilla/common.

  Did you mean this?
      hiteshrohilla/common


require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--update-with-all-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--] [<packages>]...





我尝试过:



我试图通过在Google上搜索来搜索和应用各种解决方案。但是,我找不到太多。一个相关的结果是 [ ^ ]。 >


我试图查看我的composer.json文件,如下所示





What I have tried:

I tried to search and apply various solutions by searching on Google. however, I don't find much about it. One relevant result is [^] on stackoverflow.

I tried to check my composer.json file which is as follow

{
    "name": "hiteshrohilla/common",
    "description": "common files used in development of a php project",
    "keywords": ["php","common"],
    "type": "library",
    "version": "1.0.0",
    "minimum-stability": "stable",
    "homepage": "http://hiteshrohilla.com/",
    "require": {
        "php": "^5.3.3 || ^7.0",
        "ext-mysqli": "*"
    },
    "require-dev": {},
    "conflict": {},
    "repositories": [
        {
            "type": "path",
            "url": "https://github.com/hitswa/composer-package-test.git"
        }
    ],
    "license": ["Creative Commons Attribution-ShareAlike 4.0 International License",
                "Creative Commons Attribution 3.0 License"],
    "authors": [
        {
            "name": "Er. Hitesh Kumar (Rohilla)",
            "email": "rohilla.hitesh@gmail.com",
            "homepage": "http://hiteshrohilla.com/",
            "role": "Developer"
        }
    ],
    "support": {
        "email": "rohilla.hitesh@gmail.com"
    },
    "time": "2018-01-15 00:00:00",
    "autoload":{
        "psr-4":{
            "Hiteshrohilla\\":"src/Hiteshrohilla"
        }
    }
}





请让我知道有什么不对我正在做并指导我并纠正我。

================================ ======================================



更新:



现在我可以从作曲家那里获取包了。怎么样?通过以下方式



步骤01:我创建了一个空的项目目录,我想要获取此包。



步骤02:然后我制作了一个composer.json文件并添加以下代码





Please let me know what wrong I am doing and guide me and correct me.
======================================================================

UPDATE:

Now I am able to fetch the package from the composer. How? by following way

Step 01: I made an empty project directory where I want to fetch this package.

Step 02: Then I made a composer.json file and add following code to it

{
    "name": "testapp",
    "require": {
        "hiteshrohilla/common": "dev-master"
    }
}





步骤03:然后我在终端的项目目录地址运行以下命令





Step 03: Then I run following command in terminal at this address of project directory

composer install





======= ================================================== =



好​​吧,我仍然认为为什么我无法直接从composer CLI获取存储库。也许是因为GitHub上没有发布。



==========================================================

Well, I still think why I am unable to fetch the repository directly from composer CLI. Maybe because there is no release on GitHub.

推荐答案

这是因为你的包代码在git仓库中不包含任何标签。

使用下面的行添加标记,然后将其推送到repo。

例如

git tag -a 1.0.0

git push --tags



之后你可以使用作曲家需要hiteshrohilla / common。



谢谢,

Afraz Ahmad
This is because of your package code does not contain any tags in git repository.
Use below lines to add tag and then push it to repo.
e.g.
git tag -a 1.0.0
git push --tags

After that you can use composer require hiteshrohilla/common.

Thanks,
Afraz Ahmad


这篇关于[Invalidargumentexception]在composer需要时找不到包错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆