craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.28k stars 635 forks source link

Getting "failed to open stream: No such file or directory in /autoload.php on line 5" when using Craft 3.4.0+ on site #6773

Closed aaronbushnell closed 4 years ago

aaronbushnell commented 4 years ago

Description

We're currently running a site on Craft version 3.3.4.1 and are updating to 3.5.8. However, we're receiving this error in our staging environment:

Warning: require_once(//composer/autoload_real.php): failed to open stream: No such file or directory in /autoload.php on line 5

Fatal error: require_once(): Failed opening required '//composer/autoload_real.php' (include_path='.:/opt/sp/php7.3/lib/php') in /autoload.php on line 5

It looks like this problem happens when I jump from 3.3.20.1 to 3.4.0 so something in 3.4.0+ is causing this issue in this environment.

Oddly enough, both autoload.php and autoload_real.php exist and this is not a problem in my local environment so not sure why this is occurring. Happy to provide a composer.json/lock file!

Additional info

brandonkelly commented 4 years ago

That is a Composer-generated file, so this is going to be due to an issue with the Composer install/update, not directly related to any Craft release.

Try nuking your vendor/ folder and then running composer install.

aaronbushnell commented 4 years ago

Hey @brandonkelly — yeah, unfortunately no dice with blowing away the vendor folder, composer.lock and even using Composer’s cache clearing command. It’s so strange. I can use the exact same dependencies in composer.json but the second I bump Craft to 3.4.0 I start getting this

andris-sevcenko commented 4 years ago

@aaronbushnell Can you try running composer dump-autoload?

aaronbushnell commented 4 years ago

Hey @andris-sevcenko! Here's the result of my tests:

✅ Works as expected

{
  "require": {
    "craftcms/cms": "3.3.20.1",
    "vlucas/phpdotenv": "^2.4.0"
  },
  "autoload": {
    "psr-4": {
      "modules\\": "modules/"
    }
  },
  "config": {
    "sort-packages": true,
    "optimize-autoloader": true,
    "platform": {
      "php": "7.0"
    }
  },
  "scripts": {
    "post-root-package-install": [
      "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ]
  }
}

Then I run: rm -rf vendor composer.lock && composer install

❌ Does not work

{
  "require": {
    "craftcms/cms": "3.4.0",
    "vlucas/phpdotenv": "^2.4.0"
  },
  "autoload": {
    "psr-4": {
      "modules\\": "modules/"
    }
  },
  "config": {
    "sort-packages": true,
    "optimize-autoloader": true,
    "platform": {
      "php": "7.0"
    }
  },
  "scripts": {
    "post-root-package-install": [
      "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ]
  }
}

rm -rf vendor composer.lock && composer install

This still does not work after I do composer dump-autoload.

Composer info

Here's some details on the server's version of composer when I simply run composer in the command line:

   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 1.10.10 2020-08-03 11:35:19

Happy to provide any other tests or diagnostics that are useful!

aaronbushnell commented 4 years ago

Here's what I'm seeing when things are not working as expected:


Warning: require_once(//composer/autoload_real.php): failed to open stream: No such file or directory in /autoload.php on line 5

Fatal error: require_once(): Failed opening required '//composer/autoload_real.php' (include_path='.:/opt/sp/php7.3/lib/php') in /autoload.php on line 5

Screen Shot 2020-09-05 at 11 26 57 AM

aaronbushnell commented 4 years ago

FWIW I dropped a composer.phar at version 1.8.0 (the one I use locally) on the server and tried installing/dump-autoload with that and no dice still

brandonkelly commented 4 years ago

@aaronbushnell I’m not sure why it’s not working for you. I just tried your non-working composer.json file locally, and everything installed just fine. Have you tried on a different computer?

aaronbushnell commented 4 years ago

I have! It seems to only be happening on a ServerPilot+Digital Ocean server. No clue why that is. Anything you can think of that would make this occur with just the change to Craft v3.4+?

If so I can dive deeper and see if I can correct the problem/send a PR (if it’s relevant)

brandonkelly commented 4 years ago

Sorry, completely stumped. Composer doesn’t care about the contents of the packages it installs, so there’s really nothing Craft could be doing to mess it up if we tried.

Have you tried changing it to ^3.4.0 or ~3.4.0 ?

aaronbushnell commented 4 years ago

Okay, a bit more info here, but not sure what to make of it!

I went into the autoload_real.php file provided by Composer and started echoing out the files it's trying to load to see which of them throws the error. Here's what I get:

/app/vendor/composer/../symfony/polyfill-mbstring/bootstrap.php

/app/vendor/composer/../symfony/polyfill-intl-normalizer/bootstrap.php

/app/vendor/composer/../symfony/polyfill-php72/bootstrap.php

/app/vendor/composer/../symfony/polyfill-php70/bootstrap.php

/app/vendor/composer/../symfony/polyfill-intl-idn/bootstrap.php

/app/vendor/composer/../ezyang/htmlpurifier/library/HTMLPurifier.composer.php

/app/vendor/composer/../symfony/polyfill-iconv/bootstrap.php

/app/vendor/composer/../symfony/polyfill-ctype/bootstrap.php

/app/vendor/composer/../symfony/polyfill-intl-grapheme/bootstrap.php

/app/vendor/composer/../swiftmailer/swiftmailer/lib/swift_required.php

/app/vendor/composer/../voku/portable-utf8/bootstrap.php

/app/vendor/composer/../laminas/laminas-zendframework-bridge/src/autoload.php

Warning: require_once(//composer/autoload_real.php): failed to open stream: No such file or directory in /autoload.php on line 5

Fatal error: require_once(): Failed opening required '//composer/autoload_real.php' (include_path='.:/opt/sp/php7.3/lib/php') in /autoload.php on line 5

It looks like it has something to do with laminas-zendframework-bridge which makes sense as that was a dependency change added in 3.4.0-RC1! https://github.com/craftcms/cms/commit/4c37b37486ed9610927fa2529ef5a2003f2fa207

However, I still don't totally understand why this would be an issue. I'll reach out there to see if there's some info on this!

brandonkelly commented 4 years ago

Ah interesting, I didn’t realize laminas-feed was doing anything weird with autoloading. Looking into this on my end as well.

froschdesign commented 4 years ago

@brandonkelly Maybe I'm wrong but the problem lies much earlier:

Warning: require_once(//composer/autoload_real.php): failed to open stream: No such file or directory in /autoload.php on line 5

Fatal error: require_once(): Failed opening required '//composer/autoload_real.php' (include_path='.:/opt/sp/php7.3/lib/php') in /autoload.php on line 5

The autoload.php looks like this:

<?php

// autoload.php @generated by Composer

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit196de3e2042c3dacfc824a5363515f20::getLoader();

And line 5 contains: require_once __DIR__ . '/composer/autoload_real.php';

The same problem arises also with a different configuration:

{
  "require": {
    "psr/http-factory": "^1.0"
  }
}

…because loading fails at all.

@aaronbushnell Can you recheck this?

aaronbushnell commented 4 years ago

Sorry not sure I’m totally tracking @froschdesign. Recheck what exactly?

I think this is isolated to the laminas-feed package! It was introduced in Craft 3.4 which is when this problem happens for me.

This is also happens if I setup a very minimal test case just using the laminas-feed package so I think it’s the culprit here. https://github.com/laminas/laminas-feed/issues/22#issue-694201516

froschdesign commented 4 years ago

@aaronbushnell The problem is line 5 in the file autoload.php. Craft CMS, laminas-feed or any other installed package via Composer is never reached.

Recheck what exactly?

With any other Composer configuration like this:

{
  "require": {
    "psr/http-factory": "^1.0"
  }
}
aaronbushnell commented 4 years ago

Ah, sorry, yes!

I tried changing the dependencies I had in package.json to use an earlier version of Craft CMS that didn’t use laminas-feed and it worked as expected.

Then, when I changed that version to 3.4.0 (the one that requires laminas-feed) it doesn’t work.

I know what you mean though. I thought it was a problem at a higher level but it appears the error message is a bit of a red herring here.

Notably because of this debugging process I took: https://github.com/craftcms/cms/issues/6773#issuecomment-687657018

It seems there’s nothing wrong with Composer loading packages in general. I can get it to load previous versions of the CMS but it’s when I pull in this particular package I start seeing the problem.

But I’m happy to run any debugging steps that might be useful for you! I have SSH access to the problematic server so happy to run any diagnostics that are useful.

weierophinney commented 4 years ago

So, I decided to try something to figure out what was going on.

I created a directory that contained the following:

I then ran composer install, followed by php test.php.

I had no autoloading issues. No errors at all. I even tried running on each of PHP 7.0 and 7.4 to see if there was any difference due to PHP version (I noted the "platform" configuration).

Can you indicate the exact PHP and Composer versions with which you observe the issues? And maybe provide the composer.lock that demonstrates the issue (as installing against that may help reproduce the issue)?

aaronbushnell commented 4 years ago

Yeah, same problem @weierophinney. Here's the full set of steps I've performed:

# Get PHP version info
$ php -v
PHP 7.0.33 (cli) (built: May 20 2012 07:00:00) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.33, Copyright (c) 1999-2017, by Zend Technologies

# Get Composer version info
$ composer
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 1.10.10 2020-08-03 11:35:19

# Created an empty .env file.
# Created an empty modules/ directory
# Added a composer.json with the specified contents
# Added test.php file with the specified contents

# Run `composer install`
$ composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 91 installs, 0 updates, 0 removals
  - Installing yiisoft/yii2-composer (2.0.10): Loading from cache
  - Installing craftcms/plugin-installer (1.5.5): Loading from cache
  - Installing laminas/laminas-zendframework-bridge (1.1.0): Loading from cache
  - Installing laminas/laminas-stdlib (3.2.1): Loading from cache
  - Installing laminas/laminas-escaper (2.6.1): Loading from cache
  - Installing laminas/laminas-feed (2.12.3): Loading from cache
  - Installing symfony/polyfill-php72 (v1.18.1): Loading from cache
  - Installing paragonie/random_compat (v9.99.99): Loading from cache
  - Installing symfony/polyfill-php70 (v1.18.1): Loading from cache
  - Installing symfony/polyfill-intl-normalizer (v1.18.1): Loading from cache
  - Installing symfony/polyfill-intl-idn (v1.18.1): Loading from cache
  - Installing symfony/polyfill-mbstring (v1.18.1): Loading from cache
  - Installing symfony/polyfill-iconv (v1.18.1): Loading from cache
  - Installing doctrine/lexer (1.0.2): Loading from cache
  - Installing egulias/email-validator (2.1.20): Loading from cache
  - Installing swiftmailer/swiftmailer (v6.2.3): Loading from cache
  - Installing craftcms/cms (3.4.0): Loading from cache
  - Installing ezyang/htmlpurifier (v4.13.0): Loading from cache
  - Installing cebe/markdown (1.2.1): Loading from cache
  - Installing yiisoft/yii2 (2.0.32): Loading from cache
  - Installing yiisoft/yii2-swiftmailer (2.1.2): Loading from cache
  - Installing symfony/var-dumper (v3.3.6): Loading from cache
  - Installing nikic/php-parser (v4.9.1): Loading from cache
  - Installing psr/container (1.0.0): Loading from cache
  - Installing psr/log (1.1.3): Loading from cache
  - Installing symfony/debug (v3.3.6): Loading from cache
  - Installing symfony/console (v3.3.6): Loading from cache
  - Installing dnoegel/php-xdg-base-dir (v0.1.1): Loading from cache
  - Installing symfony/polyfill-intl-grapheme (v1.18.1): Loading from cache
  - Installing symfony/polyfill-ctype (v1.18.1): Loading from cache
  - Installing psy/psysh (v0.10.4): Loading from cache
  - Installing yiisoft/yii2-shell (2.0.4): Loading from cache
  - Installing symfony/process (v3.3.6): Loading from cache
  - Installing yiisoft/yii2-queue (2.3.0): Loading from cache
  - Installing opis/closure (3.5.7): Loading from cache
  - Installing yiisoft/yii2-debug (2.1.13): Loading from cache
  - Installing yii2tech/ar-softdelete (1.0.4): Loading from cache
  - Installing webonyx/graphql-php (v0.12.6): Loading from cache
  - Installing voku/email-check (3.0.2): Loading from cache
  - Installing true/punycode (v2.1.1): Loading from cache
  - Installing voku/portable-ascii (1.5.3): Loading from cache
  - Installing voku/portable-utf8 (5.4.47): Loading from cache
  - Installing voku/anti-xss (4.1.28): Loading from cache
  - Installing voku/stop-words (2.0.1): Loading from cache
  - Installing voku/urlify (4.1.1): Loading from cache
  - Installing webmozart/assert (1.9.1): Loading from cache
  - Installing phpdocumentor/reflection-common (1.0.1): Loading from cache
  - Installing phpdocumentor/type-resolver (0.5.1): Loading from cache
  - Installing phpdocumentor/reflection-docblock (4.3.4): Loading from cache
  - Installing voku/arrayy (5.15.0): Loading from cache
  - Installing voku/stringy (5.1.1): Loading from cache
  - Installing twig/twig (v2.12.5): Loading from cache
  - Installing symfony/yaml (v3.3.6): Loading from cache
  - Installing seld/cli-prompt (1.0.3): Loading from cache
  - Installing pixelandtonic/imagine (1.2.2.1): Loading from cache
  - Installing tubalmartin/cssmin (v4.1.1): Loading from cache
  - Installing pimple/pimple (v3.2.3): Loading from cache
  - Installing mrclay/props-dic (3.0.0): Loading from cache
  - Installing container-interop/container-interop (1.2.0): Downloading (100%)         
  - Installing mrclay/jsmin-php (2.4.0): Loading from cache
  - Installing monolog/monolog (1.25.5): Loading from cache
  - Installing marcusschwarz/lesserphp (v0.5.4): Loading from cache
  - Installing intervention/httpauth (2.1.0): Loading from cache
  - Installing mrclay/minify (3.0.10): Loading from cache
  - Installing mikehaertl/php-shellcommand (1.6.2): Loading from cache
  - Installing psr/http-message (1.0.1): Loading from cache
  - Installing ralouphie/getallheaders (3.0.3): Loading from cache
  - Installing guzzlehttp/psr7 (1.6.1): Loading from cache
  - Installing guzzlehttp/promises (v1.3.1): Loading from cache
  - Installing guzzlehttp/guzzle (6.5.5): Loading from cache
  - Installing league/oauth2-client (2.5.0): Loading from cache
  - Installing league/flysystem (1.0.70): Loading from cache
  - Installing enshrined/svg-sanitize (0.13.3): Loading from cache
  - Installing elvanto/litemoji (1.4.4): Loading from cache
  - Installing creocoder/yii2-nested-sets (0.9.0): Loading from cache
  - Installing craftcms/server-check (1.1.9): Loading from cache
  - Installing craftcms/oauth2-craftid (1.0.0.1): Loading from cache
  - Installing seld/phar-utils (1.1.1): Loading from cache
  - Installing symfony/filesystem (v3.3.6): Loading from cache
  - Installing symfony/finder (v3.3.6): Loading from cache
  - Installing seld/jsonlint (1.8.2): Loading from cache
  - Installing composer/spdx-licenses (1.5.4): Loading from cache
  - Installing composer/semver (1.7.0): Downloading (100%)         
  - Installing composer/ca-bundle (1.2.8): Loading from cache
  - Installing justinrainbow/json-schema (5.2.10): Loading from cache
  - Installing composer/composer (1.6.3): Loading from cache
  - Installing laminas/laminas-validator (2.12.2): Downloading (100%)         
  - Installing laminas/laminas-uri (2.7.1): Downloading (100%)         
  - Installing laminas/laminas-loader (2.6.1): Downloading (100%)         
  - Installing laminas/laminas-http (2.13.0): Downloading (100%)         
  - Installing vlucas/phpdotenv (v2.6.6): Loading from cache
laminas/laminas-feed suggests installing laminas/laminas-cache (Laminas\Cache component, for optionally caching feeds between requests)
laminas/laminas-feed suggests installing laminas/laminas-db (Laminas\Db component, for use with PubSubHubbub)
laminas/laminas-feed suggests installing laminas/laminas-servicemanager (Laminas\ServiceManager component, for easily extending ExtensionManager implementations)
paragonie/random_compat suggests installing ext-libsodium (Provides a modern crypto API that can be used to generate random bytes.)
craftcms/cms suggests installing ext-imagick (Adds support for more image processing formats and options.)
symfony/var-dumper suggests installing ext-symfony_debug
symfony/console suggests installing symfony/event-dispatcher
psy/psysh suggests installing ext-pdo-sqlite (The doc command requires SQLite to work.)
psy/psysh suggests installing hoa/console (A pure PHP readline implementation. You'll want this if your PHP install doesn't already support readline or libedit.)
yiisoft/yii2-queue suggests installing yiisoft/yii2-redis (Need for Redis queue.)
yiisoft/yii2-queue suggests installing pda/pheanstalk (Need for Beanstalk queue.)
yiisoft/yii2-queue suggests installing php-amqplib/php-amqplib (Need for AMQP queue.)
yiisoft/yii2-queue suggests installing enqueue/amqp-lib (Need for AMQP interop queue.)
yiisoft/yii2-queue suggests installing ext-gearman (Need for Gearman queue.)
yiisoft/yii2-queue suggests installing aws/aws-sdk-php (Need for aws SQS.)
yiisoft/yii2-queue suggests installing enqueue/stomp (Need for Stomp queue.)
webonyx/graphql-php suggests installing react/promise (To leverage async resolving on React PHP platform)
pixelandtonic/imagine suggests installing ext-imagick (to use the Imagick implementation)
pixelandtonic/imagine suggests installing ext-gmagick (to use the Gmagick implementation)
monolog/monolog suggests installing graylog2/gelf-php (Allow sending log messages to a GrayLog2 server)
monolog/monolog suggests installing sentry/sentry (Allow sending log messages to a Sentry server)
monolog/monolog suggests installing doctrine/couchdb (Allow sending log messages to a CouchDB server)
monolog/monolog suggests installing ruflin/elastica (Allow sending log messages to an Elastic Search server)
monolog/monolog suggests installing php-amqplib/php-amqplib (Allow sending log messages to an AMQP server using php-amqplib)
monolog/monolog suggests installing ext-amqp (Allow sending log messages to an AMQP server (1.0+ required))
monolog/monolog suggests installing ext-mongo (Allow sending log messages to a MongoDB server)
monolog/monolog suggests installing mongodb/mongodb (Allow sending log messages to a MongoDB server via PHP Driver)
monolog/monolog suggests installing aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB)
monolog/monolog suggests installing rollbar/rollbar (Allow sending log messages to Rollbar)
monolog/monolog suggests installing php-console/php-console (Allow sending log messages to Google Chrome)
mrclay/minify suggests installing firephp/firephp-core (Use FirePHP for Log messages)
mrclay/minify suggests installing meenie/javascript-packer (Keep track of the Packer PHP port using Composer)
guzzlehttp/psr7 suggests installing zendframework/zend-httphandlerrunner (Emit PSR-7 responses)
league/flysystem suggests installing league/flysystem-eventable-filesystem (Allows you to use EventableFilesystem)
league/flysystem suggests installing league/flysystem-rackspace (Allows you to use Rackspace Cloud Files)
league/flysystem suggests installing league/flysystem-azure (Allows you to use Windows Azure Blob storage)
league/flysystem suggests installing league/flysystem-webdav (Allows you to use WebDAV storage)
league/flysystem suggests installing league/flysystem-aws-s3-v2 (Allows you to use S3 storage with AWS SDK v2)
league/flysystem suggests installing league/flysystem-aws-s3-v3 (Allows you to use S3 storage with AWS SDK v3)
league/flysystem suggests installing spatie/flysystem-dropbox (Allows you to use Dropbox storage)
league/flysystem suggests installing srmklive/flysystem-dropbox-v2 (Allows you to use Dropbox storage for PHP 5 applications)
league/flysystem suggests installing league/flysystem-cached-adapter (Flysystem adapter decorator for metadata caching)
league/flysystem suggests installing league/flysystem-sftp (Allows you to use SFTP server storage via phpseclib)
league/flysystem suggests installing league/flysystem-ziparchive (Allows you to use ZipArchive adapter)
laminas/laminas-validator suggests installing laminas/laminas-db (Laminas\Db component, required by the (No)RecordExists validator)
laminas/laminas-validator suggests installing laminas/laminas-filter (Laminas\Filter component, required by the Digits validator)
laminas/laminas-validator suggests installing laminas/laminas-i18n (Laminas\I18n component to allow translation of validation error messages)
laminas/laminas-validator suggests installing laminas/laminas-i18n-resources (Translations of validator messages)
laminas/laminas-validator suggests installing laminas/laminas-math (Laminas\Math component, required by the Csrf validator)
laminas/laminas-validator suggests installing laminas/laminas-servicemanager (Laminas\ServiceManager component to allow using the ValidatorPluginManager and validator chains)
laminas/laminas-validator suggests installing laminas/laminas-session (Laminas\Session component, ^2.8; required by the Csrf validator)
laminas/laminas-http suggests installing paragonie/certainty (For automated management of cacert.pem)
Package container-interop/container-interop is abandoned, you should avoid using it. Use psr/container instead.
Writing lock file
Generating optimized autoload files
23 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

# Run `php test.php`
$ php test.php 
PHP Warning:  require_once(//composer/autoload_real.php): failed to open stream: No such file or directory in /autoload.php on line 5

Warning: require_once(//composer/autoload_real.php): failed to open stream: No such file or directory in /autoload.php on line 5
PHP Fatal error:  require_once(): Failed opening required '//composer/autoload_real.php' (include_path='.:/opt/sp/php7.0/lib/php') in /autoload.php on line 5

Fatal error: require_once(): Failed opening required '//composer/autoload_real.php' (include_path='.:/opt/sp/php7.0/lib/php') in /autoload.php on line 5

Then I tried using an earlier version of Craft that didn't have laminas-feed but I'm still including laminas/laminas-http, and got the same error

# Remove composer.lock and vendor/
$ rm -rf vendor/ composer.lock

# Change Craft to version 3.3.20.1 (before including laminas-feed) in composer.json
# Run `composer install`
$ composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 78 installs, 0 updates, 0 removals
  - Installing yiisoft/yii2-composer (2.0.10): Loading from cache
  - Installing craftcms/plugin-installer (1.5.5): Loading from cache
  - Installing laminas/laminas-zendframework-bridge (1.1.0): Loading from cache
  - Installing laminas/laminas-stdlib (3.2.1): Loading from cache
  - Installing laminas/laminas-escaper (2.6.1): Loading from cache
  - Installing zendframework/zend-feed (2.12.0): Loading from cache
  - Installing symfony/polyfill-php72 (v1.18.1): Loading from cache
  - Installing paragonie/random_compat (v9.99.99): Loading from cache
  - Installing symfony/polyfill-php70 (v1.18.1): Loading from cache
  - Installing symfony/polyfill-intl-normalizer (v1.18.1): Loading from cache
  - Installing symfony/polyfill-intl-idn (v1.18.1): Loading from cache
  - Installing symfony/polyfill-mbstring (v1.18.1): Loading from cache
  - Installing symfony/polyfill-iconv (v1.18.1): Loading from cache
  - Installing doctrine/lexer (1.0.2): Loading from cache
  - Installing egulias/email-validator (2.1.20): Loading from cache
  - Installing swiftmailer/swiftmailer (v6.2.3): Loading from cache
  - Installing craftcms/cms (3.3.20.1): Loading from cache
  - Installing ezyang/htmlpurifier (v4.13.0): Loading from cache
  - Installing cebe/markdown (1.2.1): Loading from cache
  - Installing yiisoft/yii2 (2.0.31): Loading from cache
  - Installing yiisoft/yii2-swiftmailer (2.1.2): Loading from cache
  - Installing symfony/process (v3.3.6): Loading from cache
  - Installing yiisoft/yii2-queue (2.1.0): Loading from cache
  - Installing opis/closure (3.5.7): Loading from cache
  - Installing yiisoft/yii2-debug (2.1.13): Loading from cache
  - Installing yii2tech/ar-softdelete (1.0.4): Loading from cache
  - Installing webonyx/graphql-php (v0.12.6): Loading from cache
  - Installing voku/email-check (3.0.2): Loading from cache
  - Installing true/punycode (v2.1.1): Loading from cache
  - Installing symfony/polyfill-intl-grapheme (v1.18.1): Loading from cache
  - Installing voku/portable-ascii (1.5.3): Loading from cache
  - Installing voku/portable-utf8 (5.4.47): Loading from cache
  - Installing voku/anti-xss (4.1.28): Loading from cache
  - Installing voku/stop-words (2.0.1): Loading from cache
  - Installing voku/urlify (4.1.1): Loading from cache
  - Installing symfony/polyfill-ctype (v1.18.1): Loading from cache
  - Installing webmozart/assert (1.9.1): Loading from cache
  - Installing phpdocumentor/reflection-common (1.0.1): Loading from cache
  - Installing phpdocumentor/type-resolver (0.5.1): Loading from cache
  - Installing phpdocumentor/reflection-docblock (4.3.4): Loading from cache
  - Installing voku/arrayy (5.15.0): Loading from cache
  - Installing voku/stringy (5.1.1): Loading from cache
  - Installing twig/twig (v2.12.5): Loading from cache
  - Installing symfony/yaml (v3.3.6): Loading from cache
  - Installing seld/cli-prompt (1.0.3): Loading from cache
  - Installing pixelandtonic/imagine (1.2.2.1): Loading from cache
  - Installing mikehaertl/php-shellcommand (1.6.2): Loading from cache
  - Installing psr/http-message (1.0.1): Loading from cache
  - Installing ralouphie/getallheaders (3.0.3): Loading from cache
  - Installing guzzlehttp/psr7 (1.6.1): Loading from cache
  - Installing guzzlehttp/promises (v1.3.1): Loading from cache
  - Installing guzzlehttp/guzzle (6.5.5): Loading from cache
  - Installing league/oauth2-client (2.5.0): Loading from cache
  - Installing league/flysystem (1.0.70): Loading from cache
  - Installing enshrined/svg-sanitize (0.13.3): Loading from cache
  - Installing elvanto/litemoji (1.4.4): Loading from cache
  - Installing creocoder/yii2-nested-sets (0.9.0): Loading from cache
  - Installing craftcms/server-check (1.1.9): Loading from cache
  - Installing craftcms/oauth2-craftid (1.0.0.1): Loading from cache
  - Installing psr/log (1.1.3): Loading from cache
  - Installing seld/phar-utils (1.1.1): Loading from cache
  - Installing symfony/filesystem (v3.3.6): Loading from cache
  - Installing symfony/finder (v3.3.6): Loading from cache
  - Installing psr/container (1.0.0): Loading from cache
  - Installing symfony/debug (v3.3.6): Loading from cache
  - Installing symfony/console (v3.3.6): Loading from cache
  - Installing seld/jsonlint (1.8.2): Loading from cache
  - Installing composer/spdx-licenses (1.5.4): Loading from cache
  - Installing composer/semver (1.7.0): Loading from cache
  - Installing composer/ca-bundle (1.2.8): Loading from cache
  - Installing justinrainbow/json-schema (5.2.10): Loading from cache
  - Installing composer/composer (1.6.3): Loading from cache
  - Installing container-interop/container-interop (1.2.0): Loading from cache
  - Installing laminas/laminas-validator (2.12.2): Loading from cache
  - Installing laminas/laminas-uri (2.7.1): Loading from cache
  - Installing laminas/laminas-loader (2.6.1): Loading from cache
  - Installing laminas/laminas-http (2.13.0): Loading from cache
  - Installing vlucas/phpdotenv (v2.6.6): Loading from cache
zendframework/zend-feed suggests installing zendframework/zend-cache (Zend\Cache component, for optionally caching feeds between requests)
zendframework/zend-feed suggests installing zendframework/zend-db (Zend\Db component, for use with PubSubHubbub)
zendframework/zend-feed suggests installing zendframework/zend-servicemanager (Zend\ServiceManager component, for easily extending ExtensionManager implementations)
paragonie/random_compat suggests installing ext-libsodium (Provides a modern crypto API that can be used to generate random bytes.)
craftcms/cms suggests installing ext-imagick (Adds support for more image processing formats and options.)
yiisoft/yii2-queue suggests installing yiisoft/yii2-redis (Need for Redis queue.)
yiisoft/yii2-queue suggests installing pda/pheanstalk (Need for Beanstalk queue.)
yiisoft/yii2-queue suggests installing php-amqplib/php-amqplib (Need for AMQP queue.)
yiisoft/yii2-queue suggests installing enqueue/amqp-lib (Need for AMQP interop queue.)
yiisoft/yii2-queue suggests installing ext-gearman (Need for Gearman queue.)
yiisoft/yii2-queue suggests installing aws/aws-sdk-php (Need for aws SQS.)
webonyx/graphql-php suggests installing react/promise (To leverage async resolving on React PHP platform)
pixelandtonic/imagine suggests installing ext-imagick (to use the Imagick implementation)
pixelandtonic/imagine suggests installing ext-gmagick (to use the Gmagick implementation)
guzzlehttp/psr7 suggests installing zendframework/zend-httphandlerrunner (Emit PSR-7 responses)
league/flysystem suggests installing league/flysystem-eventable-filesystem (Allows you to use EventableFilesystem)
league/flysystem suggests installing league/flysystem-rackspace (Allows you to use Rackspace Cloud Files)
league/flysystem suggests installing league/flysystem-azure (Allows you to use Windows Azure Blob storage)
league/flysystem suggests installing league/flysystem-webdav (Allows you to use WebDAV storage)
league/flysystem suggests installing league/flysystem-aws-s3-v2 (Allows you to use S3 storage with AWS SDK v2)
league/flysystem suggests installing league/flysystem-aws-s3-v3 (Allows you to use S3 storage with AWS SDK v3)
league/flysystem suggests installing spatie/flysystem-dropbox (Allows you to use Dropbox storage)
league/flysystem suggests installing srmklive/flysystem-dropbox-v2 (Allows you to use Dropbox storage for PHP 5 applications)
league/flysystem suggests installing league/flysystem-cached-adapter (Flysystem adapter decorator for metadata caching)
league/flysystem suggests installing league/flysystem-sftp (Allows you to use SFTP server storage via phpseclib)
league/flysystem suggests installing league/flysystem-ziparchive (Allows you to use ZipArchive adapter)
symfony/console suggests installing symfony/event-dispatcher
laminas/laminas-validator suggests installing laminas/laminas-db (Laminas\Db component, required by the (No)RecordExists validator)
laminas/laminas-validator suggests installing laminas/laminas-filter (Laminas\Filter component, required by the Digits validator)
laminas/laminas-validator suggests installing laminas/laminas-i18n (Laminas\I18n component to allow translation of validation error messages)
laminas/laminas-validator suggests installing laminas/laminas-i18n-resources (Translations of validator messages)
laminas/laminas-validator suggests installing laminas/laminas-math (Laminas\Math component, required by the Csrf validator)
laminas/laminas-validator suggests installing laminas/laminas-servicemanager (Laminas\ServiceManager component to allow using the ValidatorPluginManager and validator chains)
laminas/laminas-validator suggests installing laminas/laminas-session (Laminas\Session component, ^2.8; required by the Csrf validator)
laminas/laminas-http suggests installing paragonie/certainty (For automated management of cacert.pem)
Package zendframework/zend-feed is abandoned, you should avoid using it. Use laminas/laminas-feed instead.
Package container-interop/container-interop is abandoned, you should avoid using it. Use psr/container instead.
Writing lock file
Generating optimized autoload files
20 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

# Run `php test.php` and get same error 
$ php test.php 
PHP Warning:  require_once(//composer/autoload_real.php): failed to open stream: No such file or directory in /autoload.php on line 5

Warning: require_once(//composer/autoload_real.php): failed to open stream: No such file or directory in /autoload.php on line 5
PHP Fatal error:  require_once(): Failed opening required '//composer/autoload_real.php' (include_path='.:/opt/sp/php7.0/lib/php') in /autoload.php on line 5

Fatal error: require_once(): Failed opening required '//composer/autoload_real.php' (include_path='.:/opt/sp/php7.0/lib/php') in /autoload.php on line 5

Finally, I tried the same version of Craft, removed laminas/laminas-http, and only used the require './vendor/autoload.php'; in the test.php file and the error no longer shows up:

# Run `composer install`
$ composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 71 installs, 0 updates, 0 removals
  - Installing yiisoft/yii2-composer (2.0.10): Loading from cache
  - Installing craftcms/plugin-installer (1.5.5): Loading from cache
  - Installing zendframework/zend-stdlib (3.2.1): Loading from cache
  - Installing zendframework/zend-escaper (2.6.1): Loading from cache
  - Installing zendframework/zend-feed (2.12.0): Loading from cache
  - Installing symfony/polyfill-php72 (v1.18.1): Loading from cache
  - Installing paragonie/random_compat (v9.99.99): Loading from cache
  - Installing symfony/polyfill-php70 (v1.18.1): Loading from cache
  - Installing symfony/polyfill-intl-normalizer (v1.18.1): Loading from cache
  - Installing symfony/polyfill-intl-idn (v1.18.1): Loading from cache
  - Installing symfony/polyfill-mbstring (v1.18.1): Loading from cache
  - Installing symfony/polyfill-iconv (v1.18.1): Loading from cache
  - Installing doctrine/lexer (1.0.2): Loading from cache
  - Installing egulias/email-validator (2.1.20): Loading from cache
  - Installing swiftmailer/swiftmailer (v6.2.3): Loading from cache
  - Installing craftcms/cms (3.3.20.1): Loading from cache
  - Installing ezyang/htmlpurifier (v4.13.0): Loading from cache
  - Installing cebe/markdown (1.2.1): Loading from cache
  - Installing yiisoft/yii2 (2.0.31): Loading from cache
  - Installing yiisoft/yii2-swiftmailer (2.1.2): Loading from cache
  - Installing symfony/process (v3.3.6): Loading from cache
  - Installing yiisoft/yii2-queue (2.1.0): Loading from cache
  - Installing opis/closure (3.5.7): Loading from cache
  - Installing yiisoft/yii2-debug (2.1.13): Loading from cache
  - Installing yii2tech/ar-softdelete (1.0.4): Loading from cache
  - Installing webonyx/graphql-php (v0.12.6): Loading from cache
  - Installing voku/email-check (3.0.2): Loading from cache
  - Installing true/punycode (v2.1.1): Loading from cache
  - Installing symfony/polyfill-intl-grapheme (v1.18.1): Loading from cache
  - Installing voku/portable-ascii (1.5.3): Loading from cache
  - Installing voku/portable-utf8 (5.4.47): Loading from cache
  - Installing voku/anti-xss (4.1.28): Loading from cache
  - Installing voku/stop-words (2.0.1): Loading from cache
  - Installing voku/urlify (4.1.1): Loading from cache
  - Installing symfony/polyfill-ctype (v1.18.1): Loading from cache
  - Installing webmozart/assert (1.9.1): Loading from cache
  - Installing phpdocumentor/reflection-common (1.0.1): Loading from cache
  - Installing phpdocumentor/type-resolver (0.5.1): Loading from cache
  - Installing phpdocumentor/reflection-docblock (4.3.4): Loading from cache
  - Installing voku/arrayy (5.15.0): Loading from cache
  - Installing voku/stringy (5.1.1): Loading from cache
  - Installing twig/twig (v2.12.5): Loading from cache
  - Installing symfony/yaml (v3.3.6): Loading from cache
  - Installing seld/cli-prompt (1.0.3): Loading from cache
  - Installing pixelandtonic/imagine (1.2.2.1): Loading from cache
  - Installing mikehaertl/php-shellcommand (1.6.2): Loading from cache
  - Installing psr/http-message (1.0.1): Loading from cache
  - Installing ralouphie/getallheaders (3.0.3): Loading from cache
  - Installing guzzlehttp/psr7 (1.6.1): Loading from cache
  - Installing guzzlehttp/promises (v1.3.1): Loading from cache
  - Installing guzzlehttp/guzzle (6.5.5): Loading from cache
  - Installing league/oauth2-client (2.5.0): Loading from cache
  - Installing league/flysystem (1.0.70): Loading from cache
  - Installing enshrined/svg-sanitize (0.13.3): Loading from cache
  - Installing elvanto/litemoji (1.4.4): Loading from cache
  - Installing creocoder/yii2-nested-sets (0.9.0): Loading from cache
  - Installing craftcms/server-check (1.1.9): Loading from cache
  - Installing craftcms/oauth2-craftid (1.0.0.1): Loading from cache
  - Installing psr/log (1.1.3): Loading from cache
  - Installing seld/phar-utils (1.1.1): Loading from cache
  - Installing symfony/filesystem (v3.3.6): Loading from cache
  - Installing symfony/finder (v3.3.6): Loading from cache
  - Installing symfony/debug (v3.3.6): Loading from cache
  - Installing symfony/console (v3.3.6): Loading from cache
  - Installing seld/jsonlint (1.8.2): Loading from cache
  - Installing composer/spdx-licenses (1.5.4): Loading from cache
  - Installing composer/semver (1.7.0): Loading from cache
  - Installing composer/ca-bundle (1.2.8): Loading from cache
  - Installing justinrainbow/json-schema (5.2.10): Loading from cache
  - Installing composer/composer (1.6.3): Loading from cache
  - Installing vlucas/phpdotenv (v2.6.6): Loading from cache
zendframework/zend-feed suggests installing zendframework/zend-cache (Zend\Cache component, for optionally caching feeds between requests)
zendframework/zend-feed suggests installing zendframework/zend-db (Zend\Db component, for use with PubSubHubbub)
zendframework/zend-feed suggests installing zendframework/zend-http (Zend\Http for PubSubHubbub, and optionally for use with Zend\Feed\Reader)
zendframework/zend-feed suggests installing zendframework/zend-servicemanager (Zend\ServiceManager component, for easily extending ExtensionManager implementations)
zendframework/zend-feed suggests installing zendframework/zend-validator (Zend\Validator component, for validating email addresses used in Atom feeds and entries when using the Writer subcomponent)
paragonie/random_compat suggests installing ext-libsodium (Provides a modern crypto API that can be used to generate random bytes.)
craftcms/cms suggests installing ext-imagick (Adds support for more image processing formats and options.)
yiisoft/yii2-queue suggests installing yiisoft/yii2-redis (Need for Redis queue.)
yiisoft/yii2-queue suggests installing pda/pheanstalk (Need for Beanstalk queue.)
yiisoft/yii2-queue suggests installing php-amqplib/php-amqplib (Need for AMQP queue.)
yiisoft/yii2-queue suggests installing enqueue/amqp-lib (Need for AMQP interop queue.)
yiisoft/yii2-queue suggests installing ext-gearman (Need for Gearman queue.)
yiisoft/yii2-queue suggests installing aws/aws-sdk-php (Need for aws SQS.)
webonyx/graphql-php suggests installing react/promise (To leverage async resolving on React PHP platform)
pixelandtonic/imagine suggests installing ext-imagick (to use the Imagick implementation)
pixelandtonic/imagine suggests installing ext-gmagick (to use the Gmagick implementation)
guzzlehttp/psr7 suggests installing zendframework/zend-httphandlerrunner (Emit PSR-7 responses)
league/flysystem suggests installing league/flysystem-eventable-filesystem (Allows you to use EventableFilesystem)
league/flysystem suggests installing league/flysystem-rackspace (Allows you to use Rackspace Cloud Files)
league/flysystem suggests installing league/flysystem-azure (Allows you to use Windows Azure Blob storage)
league/flysystem suggests installing league/flysystem-webdav (Allows you to use WebDAV storage)
league/flysystem suggests installing league/flysystem-aws-s3-v2 (Allows you to use S3 storage with AWS SDK v2)
league/flysystem suggests installing league/flysystem-aws-s3-v3 (Allows you to use S3 storage with AWS SDK v3)
league/flysystem suggests installing spatie/flysystem-dropbox (Allows you to use Dropbox storage)
league/flysystem suggests installing srmklive/flysystem-dropbox-v2 (Allows you to use Dropbox storage for PHP 5 applications)
league/flysystem suggests installing league/flysystem-cached-adapter (Flysystem adapter decorator for metadata caching)
league/flysystem suggests installing league/flysystem-sftp (Allows you to use SFTP server storage via phpseclib)
league/flysystem suggests installing league/flysystem-ziparchive (Allows you to use ZipArchive adapter)
symfony/console suggests installing symfony/event-dispatcher
Package zendframework/zend-stdlib is abandoned, you should avoid using it. Use laminas/laminas-stdlib instead.
Package zendframework/zend-escaper is abandoned, you should avoid using it. Use laminas/laminas-escaper instead.
Package zendframework/zend-feed is abandoned, you should avoid using it. Use laminas/laminas-feed instead.
Writing lock file
Generating optimized autoload files
18 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

# Run `php test.php` with success and showing now output
$ php test.php
froschdesign commented 4 years ago

@aaronbushnell Please try an installation without Craft CMS or laminas-feed. You can use my example from above.

weierophinney commented 4 years ago

Okay, I noticed something pretty interesting in the above listings, @aaronbushnell: for some reason, the zend-stdlib, zend-escaper, and zend-feed libraries are being installed, and not the laminas equivalents. When I installed locally, I only received the Laminas libraries.

I'm wondering if this is a composer caching issue? Or are you using a non-public composer repository? Something is off between what @froschdesign and I are doing and what you're doing, and I think it's environment related.

aaronbushnell commented 4 years ago

Okay, thanks for the help, all! Here's some follow-up:

✅ Works without issue:

composer.json

{
  "require": {
    "psr/http-factory": "^1.0"
  }
}

test.php

<?php

require './vendor/autoload.php';

Process

# Cleared the Composer cache using `composer clearcache`
$ composer clearcache

# Install composer deps
$ composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals
  - Installing psr/http-message (1.0.1): Downloading (100%)         
  - Installing psr/http-factory (1.0.1): Downloading (100%)         
Writing lock file
Generating autoload files

# Run test (successfully ran, no error)
$ php test.php

❌ Does not work:

composer.json

{
  "require": {
    "laminas/laminas-http": "^2.13"
  }
}

test.php

<?php

use Laminas\Feed\Reader\Reader;

require './vendor/autoload.php';

$feed = Reader::import('https://mwop.net/blog/rss.xml');

printf(
    "[%s](%s) (%s): %s\n",
    $feed->getTitle(),
    $feed->getLink(),
    $feed->getDateModified()->format('Y-m-d'),
    $feed->getDescription()
);

Process

# Removed vendor/ and composer.lock
$ rm -rf vendor/ composer.lock

# Cleared the Composer cache using `composer clearcache`
$ composer clearcache

# Install composer deps
$ composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 9 installs, 0 updates, 0 removals
  - Installing laminas/laminas-zendframework-bridge (1.1.0): Downloading (100%)         
  - Installing laminas/laminas-stdlib (3.2.1): Downloading (100%)         
  - Installing psr/container (1.0.0): Downloading (100%)         
  - Installing container-interop/container-interop (1.2.0): Downloading (100%)         
  - Installing laminas/laminas-validator (2.12.2): Downloading (100%)         
  - Installing laminas/laminas-escaper (2.6.1): Downloading (100%)         
  - Installing laminas/laminas-uri (2.7.1): Downloading (100%)         
  - Installing laminas/laminas-loader (2.6.1): Downloading (100%)         
  - Installing laminas/laminas-http (2.13.0): Downloading (100%)         
laminas/laminas-validator suggests installing laminas/laminas-db (Laminas\Db component, required by the (No)RecordExists validator)
laminas/laminas-validator suggests installing laminas/laminas-filter (Laminas\Filter component, required by the Digits validator)
laminas/laminas-validator suggests installing laminas/laminas-i18n (Laminas\I18n component to allow translation of validation error messages)
laminas/laminas-validator suggests installing laminas/laminas-i18n-resources (Translations of validator messages)
laminas/laminas-validator suggests installing laminas/laminas-math (Laminas\Math component, required by the Csrf validator)
laminas/laminas-validator suggests installing laminas/laminas-servicemanager (Laminas\ServiceManager component to allow using the ValidatorPluginManager and validator chains)
laminas/laminas-validator suggests installing laminas/laminas-session (Laminas\Session component, ^2.8; required by the Csrf validator)
laminas/laminas-validator suggests installing psr/http-message (psr/http-message, required when validating PSR-7 UploadedFileInterface instances via the Upload and UploadFile validators)
laminas/laminas-http suggests installing paragonie/certainty (For automated management of cacert.pem)
Package container-interop/container-interop is abandoned, you should avoid using it. Use psr/container instead.
Writing lock file
Generating autoload files
2 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

# Run test (shows error)
$ php test.php
PHP Warning:  require_once(//composer/autoload_real.php): failed to open stream: No such file or directory in /autoload.php on line 5

Warning: require_once(//composer/autoload_real.php): failed to open stream: No such file or directory in /autoload.php on line 5
PHP Fatal error:  require_once(): Failed opening required '//composer/autoload_real.php' (include_path='.:/opt/sp/php7.0/lib/php') in /autoload.php on line 5

Fatal error: require_once(): Failed opening required '//composer/autoload_real.php' (include_path='.:/opt/sp/php7.0/lib/php') in /autoload.php on line 5
weierophinney commented 4 years ago

What environment is this running under? Those paths (e.g., //composer/autoload_real.php) are a bit wonky. Is this a docker container? Window? WSL?

What PHP version are you using? How is it installed (system packages, third-party repo like Remi or Sury repos, brew, something else)?

I'm honestly unable to recreate what you're observing, which again comes back to: I think it's an environment-specific issue. I want to help you resolve it, but I'm missing a key detail in here somewhere, as I just can't reproduce it.

aaronbushnell commented 4 years ago

Totally understand! This is a Digital Ocean server that is managed by ServerPilot. Here's some relevant versioning in case this is useful:

$ php -v
PHP 7.0.33 (cli) (built: May 20 2012 07:00:00) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.33, Copyright (c) 1999-2017, by Zend Technologies

$ php --ini
Configuration File (php.ini) Path: /etc/php7.0-sp
Loaded Configuration File:         /etc/php7.0-sp/php.ini
Scan for additional .ini files in: /etc/php7.0-sp/conf.d
Additional .ini files parsed:      /etc/php7.0-sp/conf.d/bcmath.ini,
/etc/php7.0-sp/conf.d/bz2.ini,
/etc/php7.0-sp/conf.d/curl.ini,
/etc/php7.0-sp/conf.d/exif.ini,
/etc/php7.0-sp/conf.d/gd.ini,
/etc/php7.0-sp/conf.d/gettext.ini,
/etc/php7.0-sp/conf.d/gmp.ini,
/etc/php7.0-sp/conf.d/imap.ini,
/etc/php7.0-sp/conf.d/intl.ini,
/etc/php7.0-sp/conf.d/ldap.ini,
/etc/php7.0-sp/conf.d/mbstring.ini,
/etc/php7.0-sp/conf.d/mcrypt.ini,
/etc/php7.0-sp/conf.d/mysqli.ini,
/etc/php7.0-sp/conf.d/odbc.ini,
/etc/php7.0-sp/conf.d/opcache.ini,
/etc/php7.0-sp/conf.d/pcntl.ini,
/etc/php7.0-sp/conf.d/pdo_dblib.ini,
/etc/php7.0-sp/conf.d/pdo_mysql.ini,
/etc/php7.0-sp/conf.d/pdo_odbc.ini,
/etc/php7.0-sp/conf.d/pdo_pgsql.ini,
/etc/php7.0-sp/conf.d/pdo_sqlite.ini,
/etc/php7.0-sp/conf.d/pgsql.ini,
/etc/php7.0-sp/conf.d/shmop.ini,
/etc/php7.0-sp/conf.d/tidy.ini,
/etc/php7.0-sp/conf.d/xmlrpc.ini,
/etc/php7.0-sp/conf.d/xsl.ini

$ which php
/usr/bin/php

$ which composer
/usr/bin/composer

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.5 LTS
Release:    18.04
Codename:   bionic

$ cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04.5 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.5 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

One note. I dug into the laminas-zendframework-bridge package and it looks like there might be something happening here https://github.com/laminas/laminas-zendframework-bridge/blob/1.2.x/src/Autoloader.php#L69-L71.

This condition is firing, but I noticed that echoing getenv('COMPOSER_VENDOR_DIR') gives me nothing.

Is it possible this condition is being used (because /autoload.php is a file in this directory), but getenv('COMPOSER_VENDOR_DIR') is not being properly set? Not entirely sure here.

aaronbushnell commented 4 years ago

FWIW I can confirm that if I remove that conditional I no longer receive this error!

aaronbushnell commented 4 years ago

@weierophinney Maybe that condition needs to check that COMPOSER_VENDOR_DIR contains a value in addition to if the file exists?

weierophinney commented 4 years ago

That would explain the weird path for sure, @aaronbushnell , and could very well explain the behavior!

Would you be willing to submit a patch against laminas/laminas-zendframework-bridge to do that check, please? Ping me via a comment so I can review.

Thanks for doing the extra sleuthing!

aaronbushnell commented 4 years ago

Absolutely, thank you both, @weierophinney and @froschdesign! Here's the PR but please let me know if you'd like me to alter this in any way laminas/laminas-zendframework-bridge#71

brandonkelly commented 4 years ago

Nice detective work everyone! Will go ahead and close this now.

weierophinney commented 4 years ago

@aaronbushnell and @brandonkelly — We've just released version 1.1.1 of the bridge package. Please verify that it solves the problem; if it does, you should likely add the following to the craftcms package:

"conflict": {
    "laminas/laminas-zendframework-bridge": "<1.1.1"
}

as that will ensure you get a version containing the patch always.

aaronbushnell commented 4 years ago

Thanks so much, @weierophinney!

aaronbushnell commented 4 years ago

@brandonkelly — is anything specific needed to inherit this fix on Craft 3.x projects? Do we need to be on the latest-and-greatest for this to work?

brandonkelly commented 4 years ago

@aaronbushnell Just run composer update.

Harshna-Patel commented 3 years ago

I try to setup my project using git clone and after setup whenever i try to run my laravel project this type error are generate.please help me to how to resolve this error............

Warning: require(/var/www/html/LaravelTest/vendor/autoload.php): failed to open stream: Permission denied in /var/www/html/LaravelTest/index.php on line 24

Fatal error: require(): Failed opening required '/var/www/html/LaravelTest/vendor/autoload.php' (include_path='.:/usr/share/php') in /var/www/html/LaravelTest/index.php on line 24

brandonkelly commented 3 years ago

@Harshna-Patel That looks unrelated to the error in this issue. It’s saying PHP lacks the permissions to execute vendor/autoload.php. Perhaps you ran a Composer command as a root user or something like that. Please write into support@craftcms.com and we can help you resolve it from there.

SamuelNonoka commented 2 years ago

to delete composer.lock, vendor and try 'composer install', worked for me

manezaf8 commented 2 years ago

Try composer dump and composer clearcache

kamleshwebtech commented 11 months ago

That is a Composer-generated file, so this is going to be due to an issue with the Composer install/update, not directly related to any Craft release.

Try nuking your vendor/ folder and then running composer install.

found another issue after running composer install, error is as:

Fatal error: Trait "Carbon\Traits\ToStringFormat" not found in /Applications/MAMP/htdocs/laravelprojects/newdocapp/vendor/nesbot/carbon/src/Carbon/Traits/Converter.php on line 36