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
This results in:-
* 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.
I've tried running composer update
, composer install
, deleting the composer cache, but nothing I have tried so far resolves this error.
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.
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!
This issue is here:
/**
* 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';
}
Specifically:
return $composerJson->config->{'vendor-dir'};
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"
},
The vendor-dir
is missing. Generating the notice:
PHP Notice: Undefined property: stdClass::$vendor-dir
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.'
);
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.
EDIT:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With