Symfony2 config.php的麻烦:注意:未定义的属性:stdClass :: $ vendor-dir,缺少供应商库,如何解决? [英] Symfony2 config.php troubles: Notice: Undefined property: stdClass::$vendor-dir, Vendor libraries are missing, how to resolve?

查看:73
本文介绍了Symfony2 config.php的麻烦:注意:未定义的属性:stdClass :: $ vendor-dir,缺少供应商库,如何解决?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天,过了一会儿,我决定创建一个新的Symfony2项目。我已经在 / usr / local / bin / composer 中安装了作曲器,它已更新为最新版本:

today, after a while, I decided to create a new Symfony2 project. I have composer installed at /usr/local/bin/composer and it is updated to its latest version:

$ composer self-update
You are already using composer version etc, etc...

然后我键入了通常的命令:

Then I have typed the usual command:

composer create-project symfony/framework-standard-edition path/to/htdocs/PDFMonitor 

一切顺利:

...
Clearing the cache for the dev environment with debug true
Trying to install assets as symbolic links.
Installing assets for Symfony\Bundle\FrameworkBundle into web/bundles/framework
The assets were installed using symbolic links.
Installing assets for Sensio\Bundle\DistributionBundle into web/bundles/sensiodistribution
The assets were installed using symbolic links.

然后我打开浏览器并向symfony的 config.php请求以确保实际上一切都很顺利,但是我遇到了这个严重问题错误:

Then I opened the browser and made a request to the symfony's config.php to be sure that actually everything was smooth, but I got this Major Problem error:

此PHP通知和警告:

Notice: Undefined property: stdClass::$vendor-dir in /path/to/htdocs/PDFMonitor/app/SymfonyRequirements.php on line 751

Notice: Undefined property: stdClass::$vendor-dir in /path/to/htdocs/PDFMonitor/app/SymfonyRequirements.php on line 751

Warning: file_get_contents(/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/skeleton/app/SymfonyRequirements.php): failed to open stream: No such file or directory in /path/to/htdocs/PDFMonitor/app/SymfonyRequirements.php on line 546

我不知道为什么会这样。我有一段时间没有使用Symfony了,但是我从来没有遇到过这样的问题。

I do not know why this is happening. I didn't use Symfony for a while, but I never had such a problem.

我尝试过的方法:


  • 在项目根目录内运行 composer install composer update 。没帮助。

  • 重新安装作曲器 curl -s https:// getcomposer / installer | php 然后:


$ mv composer.phar / usr / local / bin

$ mv composer.phar /usr/local/bin

$ rm -R / path / to / htdocs / PDFMonitor`

$ rm -R /path/to/htdocs/PDFMonitor`

并再次:


$作曲者create-project symfony / framework-standard-edition path / to / htdocs / PDFMonitor

$ composer create-project symfony/framework-standard-edition path/to/htdocs/PDFMonitor

再次创建项目,但是打开 http://localhost/PDFMonitor/web/config.php 出现了先前的错误。

Again the project is created but opening http://localhost/PDFMonitor/web/config.php gave the previous errors.

我说过我从来没有遇到过这个问题。

As I said I never experienced this problem before.

我该怎么做才能使symfony再次正常工作?为什么Symfony看不到供应商?

What should I do in order to make symfony work properly again? Why Symfony doesn't see the vendors?

推荐答案

我找到了解决问题的方法:这是Symfony 2.6中的错误,

I found a solution to the problem: this is a bug in Symfony 2.6, actually 2.7 seem to have fixed it.

如果有人仍使用 composer创建项目,则创建项目symfony / framework-standard-edition ... ,其中Symfony2版本默认为2.6,并且遇到我遇到的相同问题,这是一种解决方法:

If someone still creates a project with composer create-project symfony/framework-standard-edition ..., where the Symfony2 version defaults to 2.6 and experiences the same problem I have faced, here is a workaround:

任何一个编辑 YourProject / app / SymfonyRequirements.php 第406行

YourProject / vendor /sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/skeleton/app/SymfonyRequirements.php 第406行并替换:

 is_dir($this->getComposerVendorDir()),

使用以下命令:

is_dir(__DIR__.'/../vendor/composer'),

这将消除主要问题抱怨关于供应商。然后这将删除 file_get_contents()警告:

This will remove the Major Problem complaining about the vendors. Then this will instead remove the file_get_contents() Warning:

内部 YourProject / app / SymfonyRequirements.php 并使第546行看起来像这样:

Inside YourProject/app/SymfonyRequirements.php and make line 546 look like this:

file_get_contents(__FILE__) === file_get_contents(__DIR__.'/../vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/skeleton/app/SymfonyRequirements.php'),

然后打开 localhost / YourProject / web / config.php ,您会看到漂亮的再次Symfony欢迎页面。

Then open localhost/YourProject/web/config.php and you will see the nice Symfony Welcome page again.

这篇关于Symfony2 config.php的麻烦:注意:未定义的属性:stdClass :: $ vendor-dir,缺少供应商库,如何解决?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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