vinkla / wordplate

A boilerplate for WordPress, built with Composer and designed with sensible defaults.
2.11k stars 155 forks source link

env() conflict when using illuminate/support #254

Closed fiskhandlarn closed 4 years ago

fiskhandlarn commented 4 years ago

I thought I'd make a separate issue for this problem (found in https://github.com/wordplate/wordplate/issues/250). Whenever a package that requires illuminate/support is required in a WordPlate project this leads to illuminate/support's env() function being defined before WordPlate's. This is in itself probably good for the user to know. But on top of that, the site will die with a PHP fatal error until vlucas/phpdotenv is required.

AFAIK, the WordPlate documentation mentions/recommends these packages creating this issue:

Steps to Reproduce the Problem

$ composer create-project --prefer-dist wordplate/wordplate blog
$ cd blog/
$ composer require laravel/helpers
$ php -S localhost:8000 -t public/

... generates this error in the browser:

Fatal error: Uncaught Error: Class 'PhpOption\Option' not found in blog/vendor/illuminate/support/Env.php:81 

Temporary fix

$ composer require vlucas/phpdotenv

will remove the error, but will force the project to use illuminate/support's env().

Versions

Possible solutions

vinkla commented 4 years ago

Thanks for opening a new issue on the subject @fiskhandlarn 🙌

This is probably due to a recent switch to symfony/dotenv from vlucas/phpdotenv. Do you think this issue would be fixed if we switched back? Do you get the error when you are running WordPlate 8.0 (can be enforced in composer.json)?

vinkla commented 4 years ago

This has been fixed in version 9.0 by switching back to vlucas/phpdotenv.