webNeat / lumen-generators

A collection of generators for Lumen and Laravel 5.
MIT License
352 stars 95 forks source link

Class 'Wn\Generator\CommandsServiceProvider' not found in *\vendor\laravel\lumen-framework\src\Application.php #7

Closed TiaossuP closed 8 years ago

TiaossuP commented 8 years ago

first I run composer require wn/lumen-generators

then I edit my AppServiceProvider,php like this:

    public function register()
    {
        //
        if ($this->app->environment() == 'local') {
            $this->app->register('Wn\Generator\CommandsServiceProvider');
        }
    }

I have already uncommentted 3 lines in the bootstrap/app.php file

$app->withFacades();
$app->withEloquent();
$app->register(App\Providers\AppServiceProvider::class);

but when I run php artisan list, I get this: PHP Fatal error: Class 'Wn\Generator\CommandsServiceProvider' not found in *\vendor\laravel\lumen-framework\src\Application.php on line 162

if I config a wrong composer.json? my composer.json:

{
    "name": "laravel/lumen",
    "description": "The Laravel Lumen Framework.",
    "keywords": ["framework", "laravel", "lumen"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=5.5.9",
        "laravel/lumen-framework": "5.2.*",
        "vlucas/phpdotenv": "~2.2",
        "wn/lumen-generators": "^1.1"
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "phpunit/phpunit": "~4.0"
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/",
            "database/"
        ]
    }
}
TiaossuP commented 8 years ago

ok, I get it. change

if ($this->app->environment() == 'local') {
    $this->app->register('Wn\Generators\CommandsServiceProvider');
}

to

$this->app->register('Wn\Generators\CommandsServiceProvider');

and it seems useful.

webNeat commented 8 years ago

Hello,

Based on the error message

PHP Fatal error: Class 'Wn\Generator\CommandsServiceProvider' not found in *\vendor\laravel\lumen-framework\src\Application.php on line 162

It seems that you wrote the wrong namespace for the class.

You wrote: Wn\Generator\CommandsServiceProvider

The correct one is: Wn\Generators\CommandsServiceProvider (The s in Generators was missing)

This said, the if ($this->app->environment() == 'local') has nothing to do with the error