Skip to content
Advertisement

require_once returns true instead of expected object

Both vendor/autoload.php files are basically identical:

JavaScript

In both files:

JavaScript

This has had me digging into Composer’s autoload files (which has been insightful), but I’m still perplexed:

JavaScript

Why does requiring the first file return boolean true, and not object(ComposerAutoloadClassLoader?

Update

I created a copy of vendor/autoload.php, vendor/aught.php and when I require that one, it returns the object.

Advertisement

Answer

require_once returns true instead of the return value if the file has already been included or required.

You’ll find you get true for the subdir one as well if you require it twice:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement