vlucas / phpdotenv

Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.
BSD 3-Clause "New" or "Revised" License
13.11k stars 623 forks source link

Uncaught Error: Class 'Dotenv\\Environment\\Adapter\\EnvConstAdapter' not found #429

Closed HenonoaH closed 4 years ago

HenonoaH commented 4 years ago

Getting this issue after upgrading to release 4.1.3 I load my dotenv variables like below,

$dotenv = \Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->load();

I'm wondering what might be the issue! Is it configuration changes?

Composer show result,

image (1)

Error log for reference,

image

GrahamCampbell commented 4 years ago

This is because you have installed a version of phpdotenv that is not compatible with the version of illuminate/support you have. I assume you have illuminate/support 6.x, which only works with phpdotenv 3.x: https://github.com/illuminate/support/blob/6.x/composer.json#L46. Either upgrade to illuminate/support 7.x or downgrade to phpdotenv 3.x. ;)

HenonoaH commented 4 years ago

@GrahamCampbell Thanks, man. Got it working.

mteall commented 2 years ago

I ran into this same issue. I think this issue could be avoided by listing illuminate/support (with version range) as a dependency in composer?

GrahamCampbell commented 2 years ago

No, because there are valid reasons why someone would wanna use illumninate/support without dotenv, and use dotenv with some other package for unrelated reasons.

GrahamCampbell commented 2 years ago

People need to read the output composer spits out in the suggest list. :)

mteall commented 2 years ago

Thank you for clarifying. The repo I am working on both includes both illuminate/database (which also brings in illuminate/support) and vlucas/phpdotenv. They were added long before I was involved so I didn't see suggestions output, but I do see it on the illuminate/support page in packagist now that you mention it.