问题
I'm just getting familiar with Linux servers and I'm trying to install Composer on my Ubuntu server. I think everything installed correctly except when I try to include Composer's autoloader I get a PHP error:
Warning: require(/usr/share/php/opencloud/lib/../vendor/autoload.php): failed to open stream: No such file or directory in /usr/share/php/opencloud/lib/php-opencloud.php on line 5 Fatal error: require(): Failed opening required '/usr/share/php/opencloud/lib/../vendor/autoload.php' (include_path='.:/usr/share/php') in /usr/share/php/opencloud/lib/php-opencloud.php on line 5
My composer.json is:
{
"require": {
"rackspace/php-opencloud": "v1.7.0"
}
}
And when I run "composer diag" it outputs this:
Checking composer.json: FAIL
name : is missing and it is required
description : is missing and it is required
回答1:
This is an existing bug with Composer on WINDOWS (for me, at least). Manual install style Composer.
vendor/autoload.php is not created nor is any other autoload-related content.
I try the same exact thing on Linux AND Windows (except for the platform-specific different options in the batch commands) for running Composer and installing/setting up rackspace using composer install & composer-rackspace require batch line. I get 2 different results. Autoload-related stuff is created on linux just fine. No autoload related stuff is created for Windows.
Guess Windows Composer needs more work/fixing. :(
This in general seems to be working on Linux/Ubuntu for me so far, I'll let you know if I get any problems.
回答2:
The warning seems to be pretty clear, it can't find autoload.php file. I guess some path problem in your require:
require 'vendor/autoload.php';
About the missing data you could solve adding it in your composer.json
{
"name":"YOURNAME",
"description":"YOUR DESCRIPTION",
"require":{
"rackspace/php-opencloud": "v1.7.0"
}
}
回答3:
For anyone using windows. I just had the same problem on Windows, it did not download all the files on "composer install". But after I ran "composer update" all the files including the vendor/autoload.php were download/generated
来源:https://stackoverflow.com/questions/19738983/unable-to-include-vendor-autoload-php-after-installing-composer-on-ubuntu