lumen-generators icon indicating copy to clipboard operation
lumen-generators copied to clipboard

Should (or could) this just be a development dependency?

Open judgej opened this issue 5 years ago • 2 comments

Since we should not be generating anything on production, can this package be installed as a dev only dependency?

composer require --dev wn/lumen-generators

I'm asking in case there is any production run-time component of this package that is needed by generated components that I am not aware of.

If it can, then the documentation should probably mention this, since having it in production, I assume, will provide some extra load each request.

judgej avatar Apr 10 '19 09:04 judgej

At a minimum, the App\Providers\AppServiceProvider needs to be aware that the package may not be installed.

...
use Wn\Generators\CommandsServiceProvider;
...

class AppServiceProvider extends ServiceProvider
{
    public function register()
    {
        // Install the generators.

        if ($this->app->environment() === 'local' && class_exists(CommandsServiceProvider::class)) {
            $this->app->register(CommandsServiceProvider::class);
        }
    }
   ...
}

judgej avatar Apr 10 '19 09:04 judgej

Even simpler in bootstrap/app.php:

if (class_exists(Wn\Generators\CommandsServiceProvider::class)) {
    $app->register(Wn\Generators\CommandsServiceProvider::class);
}

judgej avatar May 01 '19 15:05 judgej