nWidart / laravel-modules

Module Management In Laravel
https://docs.laravelmodules.com
MIT License
5.52k stars 959 forks source link

Class not found when creating a new module #169

Closed KSVQ closed 7 years ago

KSVQ commented 7 years ago

I am researching a viable modular approach for a large app. For now I am testing and snooping around.

I installed on a brand new instance of Laravel 5.4. (followed instructions... I think) Created App1 module successfully

Tried to create multiple modules and got this... [Symfony\Component\Debug\Exception\FatalThrowableError] Class 'Modules\App1\Providers\App1ServiceProvider' not found Modules\App1\Providers\App1ServiceProvider DOES exist however. Something I missed??

Then I tried creating ONE instance,,, App2,,, and got the same error.

The file structure in the module is not consistent with Laravel version 5.4 (I see you say it was updated for 5.4)

Thanks!

nWidart commented 7 years ago

Hello,

It looks like you forgot to autoload your modules via composer. As per the documentation in your composer.json file:

{
  "autoload": {
    "psr-4": {
      "App\\": "app/",
      "Modules\\": "Modules/"
    }
  }
}

You're free to use any module structure as you want. There are no limitations as it's autoloaded via psr-4.

KSVQ commented 7 years ago

Hmh,, That was true,, I added it (default installation composer? correct?),,, Now I get this.

[Symfony\Component\Debug\Exception\FatalThrowableError] Class 'Modular' not found

Can I delete a module? ( App1 )

nWidart commented 7 years ago

That isn't something from this package, so maybe something you bound in the IoC.

Don't forget to run composer dump-autoload after adding the modules folder to PSR-4 autoloader, so composer loads them.

KSVQ commented 7 years ago

Ok,, I won't try to patch this. I will run a fresh install and make sure I do everything again. I'll let you know how it goes.

KSVQ commented 7 years ago

Alright, so I went through both 5.3 and 5.4 and it all went through okay.

Is there a way to delete a Module (undeveloped) with Artisan and insure everything is removed correctly?

nWidart commented 7 years ago

No, but I might add a command for this. Basically you just remove the module directory. Also note #150