使用自定义packages.json找不到Composer包

时间:2014-06-24 08:10:10

标签: php json wordpress composer-php dependency-management

我有一个自定义的packages.json文件,其中包含以下内容:

{
"packages": {
    "dtcmedia/wordpress": {
        "3.9.1": {
            "name": "dtcmedia/wordpress",
            "version": "3.9.1",
            "version_normalized": "3.9.1.0",
            "source": {
                "type": "git",
                "url": "https://github.com/WordPress/WordPress",
                "reference": "3.9.1"
            },
            "dist": {
                "type": "zip",
                "url": "http://wordpress.org/wordpress-3.9.1.zip"
            },
            "require": {
                "johnpbloch/wordpress-core-installer": "~0.1"
            },
            "type": "wordpress-core"
            }
        }
    }
}

此文件位于网络服务器的webroot上。我项目中的composer.json看起来像这样:

{
"name": "dtcmedia/wp-startup",
"description": "DTC Media WordPress Startup",
"type": "wp-startup",
"authors": [
    {
        "name": "Roy Janssen",
        "homepage": "http://www.dtcmedia.nl",
        "role": "Author"
    }
],
"repositories": [
    {
        "type": "composer",
        "url": "http://dtcmediainternet.nl"
    },
    {
        "type":"composer",
        "url":"http://wpackagist.org"
    }
],
"require": {
    "php": ">=5.3.0",
    "dtcmedia/wordpress": "*",
    "dtcmedia/dtcmedia-occasionmodule-portalkoppeling": "2.0.*"
},
"extra": {
    "installer-name": "wp-startup",
    "installer-paths": {
        "content/plugins/{$name}/": ["type:wordpress-plugin"]
    }
}
}

现在使用命令$ composer show dtcmedia / wordpress会产生以下结果: [InvalidArgumentException]
 未找到包dtcmedia / wordpress

详细输出如下所示:

composer show dtcmedia/wordpress -vvv
Reading ./composer.json
Loading config file /Users/dtcmediainternet/.composer/config.json
Loading config file ./composer.json
Executing command (CWD): git describe --exact-match --tags
Executing command (CWD): git branch --no-color --no-abbrev -v
Downloading http://dtcmediainternet.nl/packages.json
Writing /Users/dtcmediainternet/.composer/cache/repo/http---dtcmediainternet.nl/packages.json into cache
Downloading http://wpackagist.org/packages.json
Writing /Users/dtcmediainternet/.composer/cache/repo/http---wpackagist.org/packages.json into cache
Downloading https://packagist.org/packages.json
Writing /Users/dtcmediainternet/.composer/cache/repo/https---packagist.org/packages.json into cache
Downloading http://wpackagist.org/p/providers-last-year$181336c94fbf892b27fbd6d7811319301623838fa3719dca410777ed789b0484.json
Writing /Users/dtcmediainternet/.composer/cache/repo/http---wpackagist.org/p-providers-last-year.json into cache
Downloading http://wpackagist.org/p/providers-old$8d2ec716409966db3ee305398eb0646d2ed0eb43b12afb18d84766da4e9c48ee.json
Writing /Users/dtcmediainternet/.composer/cache/repo/http---wpackagist.org/p-providers-old.json into cache
Downloading http://wpackagist.org/p/providers-last-2-months$509637861a8ef236e5ffa9d1e4e46018c3ac2db14989f23525f07a33554f21f7.json
Writing /Users/dtcmediainternet/.composer/cache/repo/http---wpackagist.org/p-providers-last-2-months.json into cache
Downloading http://wpackagist.org/p/providers-last-week$7493c77b849ded050c26ade395e967306a6502e010244c4217b854800df8fc12.json
Writing /Users/dtcmediainternet/.composer/cache/repo/http---wpackagist.org/p-providers-last-week.json into cache
Reading /Users/dtcmediainternet/.composer/cache/repo/https---packagist.org/p-provider-active.json from cache
Reading /Users/dtcmediainternet/.composer/cache/repo/https---packagist.org/p-provider-archived.json from cache
Reading /Users/dtcmediainternet/.composer/cache/repo/https---packagist.org/p-provider-latest.json from cache
Reading /Users/dtcmediainternet/.composer/cache/repo/https---packagist.org/p-provider-stale.json from cache



  [InvalidArgumentException]            
  Package dtcmedia/wordpress not found  



Exception trace:
 () at phar:///usr/local/bin/composer/src/Composer/Command/ShowCommand.php:111
 Composer\Command\ShowCommand->execute() at phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:241
 Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:892
 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:191
 Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:117
 Composer\Console\Application->doRun() at phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:121
 Symfony\Component\Console\Application->run() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:83
 Composer\Console\Application->run() at phar:///usr/local/bin/composer/bin/composer:43
 require() at /usr/local/bin/composer:15

1 个答案:

答案 0 :(得分:1)

您的composer.json解决了您所拥有的内容而没有问题:

C:\server\dtcmedia>composer show dtcmedia/wordpress
name     : dtcmedia/wordpress
descrip. :
keywords :
versions : 3.9.1
type     : wordpress-core
license  :
source   : [git] https://github.com/WordPress/WordPress 3.9.1
dist     : [zip] http://wordpress.org/wordpress-3.9.1.zip
names    : dtcmedia/wordpress

requires
johnpbloch/wordpress-core-installer ~0.1

可能是临时问题,例如已上传的packages.json已损坏。

另外,我建议使用johnpbloch/wordpress包用于WordPress核心。