Symfony2 config.php troubles: Note: Undefined property: stdClass :: $ vendor-dir, no vendor libraries, how to solve them?

Today, after a while, I decided to create a new Symfony2 project. I have a composer installed in /usr/local/bin/composer and it has been updated to the latest version:

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

Then I typed the usual command:

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

Everything went well:

 ... 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. 

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

Symfony2 config.php

And this is PHP notification and warning:

 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 

I do not know why this is happening. I have not used Symfony for a while, but I have never had such a problem.

What I tried:

  • Run either composer install and composer update inside the project root. Did not help.
  • Reinstall composer curl -s https://getcomposer/installer | php curl -s https://getcomposer/installer | php and then:

    $ mv composer.phar / usr / local / bin

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

    and again:

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

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

As I said, I have never experienced this problem before.

What should I do to get symfony to work correctly again? Why doesn't symfony see providers?

+1
source share
1 answer

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

If someone is still creating a project with composer create-project symfony/framework-standard-edition ... where the default version of Symfony2 is 2.6 and it is experiencing the same problem that I encountered, here is a workaround:

Or edit YourProject/app/SymfonyRequirements.php line 406 and

YourProject/vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/skeleton/app/SymfonyRequirements.php line 406 and replace:

  is_dir($this->getComposerVendorDir()), 

Wherein:

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

This will fix the main problem with supplier complaints. Then instead remove file_get_contents() Warning:

Inside YourProject/app/SymfonyRequirements.php and make the line of 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'), 

Then open localhost/YourProject/web/config.php and you will again see a nice symfony welcome page.

enter image description here

+2
source

Source: https://habr.com/ru/post/1210267/


All Articles