【问题标题】:Composer package not found with custom packages.json未使用自定义 packages.json 找到 Composer 包
【发布时间】:2014-08-14 09:51:50
【问题描述】:

我有一个自定义 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 结果如下: [无效参数异常]
找不到包 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

【问题讨论】:

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


    【解决方案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 核心包。

    【讨论】:

    • 事实证明,packages.json 确实被破坏了。
    猜你喜欢
    • 2023-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-09
    • 1970-01-01
    • 2015-04-18
    • 2015-07-11
    • 1970-01-01
    相关资源
    最近更新 更多