composer.json / cakephp

时间:2016-02-11 20:14:54

标签: php cakephp composer-php musicbrainz

我想使用:https://github.com/mikealmond/MusicBrainz 在myapp->供应商文件夹中复制了lib。安装Guzzle与作曲家和更新的作曲家。

use GuzzleHttp\Client;
use MusicBrainz\Filters\ArtistFilter;
use MusicBrainz\Filters\RecordingFilter;
use MusicBrainz\HttpAdapters\GuzzleHttpAdapter;
use MusicBrainz\MusicBrainz;

require __DIR__ . '/vendor/autoload.php';

自动加载不起作用。我尝试过很多东西但不知道,在composer.json中写什么。

Error: Class 'MusicBrainz\MusicBrainz' not found 

当我打电话时:

$brainz = new MusicBrainz(new GuzzleHttpAdapter(new Client()));

我在composer.json

中尝试过
"require-dev": {
     "vendor/MusicBrainz": "dev-master"
    },
    "repositories": [
        {
            "type": "vcs",
            "url":  "https://github.com/mikealmond/MusicBrainz.git"
        }
    ],

然后作曲家更新...... 我明白了:

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 src/musicbrainz 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://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.

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

1 个答案:

答案 0 :(得分:2)

转到Github上的链接存储库页面。在根文件夹中,单击名为composer.json的文件。搜索"name"的行。正确的文本是您必须在Composer中使用的此包的名称。

或者,转到https://packagist.org并在搜索字段中输入与实际名称相近的内容,例如musicb。会找到一些东西:https://packagist.org/search/?q=musicb

在任何情况下,您都会找到包裹名称:mikealmond/musicbrainz

现在转到命令行并输入:composer require mikealmond/musicbrainz。 Composer将完成剩下的工作,包括下载Guzzle,因为它被声明为依赖。

在该步骤之后,演示代码将起作用 - 或者至少不会因为缺少类而失败。