0

我想在我的项目中使用 jquery DataTables。由于包在 Packagist 中不可用,我试图使用 composer 来克隆 DataTables 的 git repo,但它失败了。请告知如何进行:

{
"repositories": [
    {
        "type": "vcs",
        "url":  "https://github.com/DataTables/DataTables"
    }
],
"require": {
    "DataTables/DataTables": "master"
    }
}

然后composer update返回:

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 datatables 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 min
imum-stability setting
   see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> f
or more details.

Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common
 problems.

我还想克隆/下载特定版本的 repo。

4

2 回答 2

1

然而,老问题和答案:

错误不在包的名称中(实际上是 DataTables/DataTables),而是在稳定性的指示中。如果你想要'master'分支,你需要在composer中写'dev-master'并且稳定性级别是dev。否则需要一个特定的标签。在你的情况下:

{
    "repositories": [
        {
        "type": "vcs",
        "url":  "https://github.com/DataTables/DataTables"
        }
    ],
    "require": {
    "DataTables/DataTables": "dev-master"
    }
}

将按预期工作:

root@erme:/usr/local/munk_php/jquerydatatables# composer install
Loading composer repositorInstalling dependencies (including require-dev)             
- Installing datatables/datatables (dev-master 96b7ef9)
Cloning 96b7ef9176543bbf1f1488c0f9538ad9dcc9bc01

Writing lock file
Generating autoload files
于 2014-05-26T08:37:57.890 回答
0

https://github.com/DataTables/DataTables/blob/master/component.json中的包名不是 DataTables/DataTables

尝试

"require": {
    "DataTables": "dev-master"
}
于 2013-12-04T06:44:52.370 回答