使用作曲家后出现Symfony 2.6错误:“必须安装供应商库" [英] Symfony 2.6 error after using composer: "Vendor libraries must be installed"

查看:68
本文介绍了使用作曲家后出现Symfony 2.6错误:“必须安装供应商库"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用composer创建或更新Symfony 2.6.1项目后,出现必须安装供应商库" 错误,建议运行php composer.phar install进行安装.

After creating or updating a Symfony 2.6.1 project with composer, I get a "Vendor libraries must be installed" error and it suggests running php composer.phar install to install them.

我要采取的确切步骤:-

The exact steps I'm taking:-

composer create-project symfony/framework-standard-edition my_new_project/
cd my_new_project

这似乎没有任何问题,据我所知,确实下载了所有必要的供应商软件包.但是,如果我随后运行:-

This appears to run without any problems, and as far as I can tell, does download all the necessary vendor packages. However if I then run:-

php app/check.php

结果是:-

*必须安装供应商库
  >供应商库丢失.按照以下步骤安装作曲家
  > http://getcomposer.org/中的说明.然后运行"php
  > composer.phar install"进行安装.

* Vendor libraries must be installed
  > Vendor libraries are missing. Install composer following
  > instructions from http://getcomposer.org/. Then run "php
  > composer.phar install" to install them.

我已经尝试运行composer updatecomposer install,删除了作曲家缓存,但是到目前为止我没有尝试解决此错误.

I've tried running composer update, composer install, deleting the composer cache, but nothing I have tried so far resolves this error.

通过测试众多版本的Symfony,我发现所有版本的Symfony> = 2.5.0均出现此错误.我使用Symfony< = 2.4.8以相同方式创建的任何项目都可以正常工作.

From testing numerous versions of Symfony, I get this error with all versions of Symfony >= 2.5.0. Any project I create in the same way using Symfony <= 2.4.8 works just fine.

我正在OS X上运行PHP 5.6.4(通过MacPorts安装).

I'm running PHP 5.6.4 (installed via MacPorts) on OS X.

关于作曲家,我有点菜鸟,所以任何帮助将不胜感激!

I'm bit of a noob when it comes to composer, so any help would be much appreciated!

推荐答案

此问题在这里:

/**
 * In some special setups, the vendor/ directory isn't located in the project's
 * root directory. To make this command work for every case, read Composer's
 * vendor/ directory location directly from composer.json file.
 *
 * @return string
 */
private function getComposerVendorDir()
{
    $composerJson = json_decode(file_get_contents(__DIR__.'/../composer.json'));
    if (isset($composerJson->config)) {
        return $composerJson->config->{'vendor-dir'};
    }

    return __DIR__.'/../vendor/composer';
}

特别是:

return $composerJson->config->{'vendor-dir'};

isset($composerJson->config)上的条件返回true,这将导致上面的语句.但是,当您查看生成的composer.json时:

The condition on isset($composerJson->config) returns true, which leads to the above statement. However when you look at the generated composer.json:

"config": {
    "bin-dir": "bin"
},

vendor-dir丢失.生成通知:

PHP Notice:  Undefined property: stdClass::$vendor-dir

因此该函数返回null,因此此要求失败:

Therefore the function returns null, so this requirement fails:

$this->addRequirement(
    is_dir($this->getComposerVendorDir()), // <-- HERE
    'Vendor libraries must be installed',
    'Vendor libraries are missing. Install composer following instructions from <a href="http://getcomposer.org/">http://getcomposer.org/</a>. '.
        'Then run "<strong>php composer.phar install</strong>" to install them.'
);

这是symfony/symfony-standard上的错误.可能已经修复了,但是您也可以在Github上进行修复.

This is a bug on the symfony/symfony-standard. It's likely it is already in line to be fixed, but you may as well raise it on Github.

似乎已经使用2.7了:

It looks like they already have, 2.7 uses:

$this->addRequirement(
    is_dir(__DIR__.'/../vendor/composer'),
    'Vendor libraries must be installed',
    'Vendor libraries are missing. Install composer following instructions from <a href="http://getcomposer.org/">http://getcomposer.org/</a>. '.
    'Then run "<strong>php composer.phar install</strong>" to install them.'
);

您的项目没有错,这只是标准版中的一个错误.只要您正确地自动加载课程,就可以了.

There is nothing wrong with your project, its just a bug in the standard edition. So long as you are autoloading classes properly you are fine.

这篇关于使用作曲家后出现Symfony 2.6错误:“必须安装供应商库"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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