简体   繁体   中英

Unable to include “vendor/autoload.php” after installing Composer on Ubuntu

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

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.

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" 
    }
}

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM