laravel / lumen-framework

The Laravel Lumen Framework.
https://lumen.laravel.com
MIT License
1.48k stars 419 forks source link

lumen-framework depends on vlucas/phpdotenv but package isn't required #918

Closed bshaffer closed 5 years ago

bshaffer commented 5 years ago

Description:

The laravel/lumen-framework package suggests installing vlucas/phpdotenv, but the vlucas/phpdotenv package is a hard dependency of the laravel/lumen-framework package. The helper env is autoloaded by composer, which depends on DotenvFactory, and there is no way to run the framework AFAIK without triggering a Class Not Found error.

Steps To Reproduce:

Require Lumen Framework:

composer require laravel/lumen-framework

Create the app:

// index.php
require_once __DIR__ . '/vendor/autoload.php';
$app = new Laravel\Lumen\Application(__DIR__);
$app->run();

Run the web server and visit localhost:8080 in your browser:

php -S localhost:8080

The result is the following:

Fatal error: Uncaught Error: Class 'Dotenv\Environment\DotenvFactory' not found in vendor/illuminate/support/helpers.php:646 Stack trace: 
#0 /vendor/laravel/lumen-framework/src/Application.php(89): env('APP_TIMEZONE')
#1 index.php(18): Laravel\Lumen\Application->__construct('...')
#2 {main} thrown in vendor/illuminate/support/helpers.php on line 646

Solution

Make env not rely on vlucas/phpdotenv OR add vlucas/phpdotenv as a requirement for laravel/lumen-framework.

driesvints commented 5 years ago

I think this PR made it a hard dependency so we should indeed implement it as such: https://github.com/laravel/lumen-framework/pull/879