Laravel-modules: [Module] Service provider not found on production server

Created on 1 Aug 2016  ·  16Comments  ·  Source: nWidart/laravel-modules

I created Employee Module, but error message is appearing on production server like that

[Symfony\Component\Debug\Exception\FatalThrowableError]               
 Class 'Modules\Employee\Providers\EmployeeServiceProvider' not found

Development -> Mac
Production -> Ubuntu server 14.04, Nginx

I also run a composer dump-autoload and php artisan clear-compiled on production.

Application is running stable on development server.
I don't exactly know this error message. Please help me. Thanks

Most helpful comment

have a look at app/config/modules.php

in line ~65 , change 'modules' => base_path('Modules'),
to 'modules' => base_path('modules'),

this solved the problem for us ( coming from named routes not working)
I am not sure if the different naming is general bug, so if you run php artisan module: make test
it will create a 'Modues' dir, even if 'modules' is present

All 16 comments

Hello,

If you're having this on production and not locally it's quite possible it's a Case sensitive issue.

Double check what casings the files have.

As @nWidart pointed out: make sure that file location on production server is exactly Modules/Employee/Providers/EmployeeServiceProvider.php matching all lower and upper case letters. It is a common problem when people develop using Windows (Mac also by default) (which _ignore upper case in file name_), everything works fine and when they upload to production (which is usually unix based system that _does not ignore upper case in file name_) they see file not found errors.

have a look at app/config/modules.php

in line ~65 , change 'modules' => base_path('Modules'),
to 'modules' => base_path('modules'),

this solved the problem for us ( coming from named routes not working)
I am not sure if the different naming is general bug, so if you run php artisan module: make test
it will create a 'Modues' dir, even if 'modules' is present

I solved, thanks @m-behr 👍
but error message is appearing like thatNotFoundHttpException in RouteCollection.php line 161:
I think, this package was not tested on Ubuntu/Linux OS. How can I fix Sir?

@KyawNaingTun i run several apps using this package on Ubuntu and i comply with PSR4 naming and had no issues.
Folder name Modules namespace Modules and everything good.

And also composer.json have correct information :

  "autoload": {
    "psr-4": {
      "Modules\\MyModule\\": ".",
      "Modules\\": "Modules/"
    }
  },

I solved all errors. :D Thank everybody
Solutions:

  1. Root module folder was changed from Modules to modules
  2. please go to comment of @m-behr :D

But this still suggests me that it's not a legit fix. You just somewhere have lowercase modules in your namespace. The uppercase Modules is correct. Almost as if your modules would not be namespaced under Modules root but excluding that.

But i'm glad it worked out for you :)

Hello @KyawNaingTun @nWidart
Thanks
Please,
When I run this command: $ php artisan module:make MyModule
the Module folder is generated out of app folder.
Why? :S
My-project/
Modules/
app/
bootstrap/
.
.

I modified the modules.php file, this line:
'modules' => base_path('app/Modules'),

That works, but I run this command again: $ php artisan module:make OtherModule
I have this error:
[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'Modules\Frontend\Providers\MyModuleServiceProvider' not found

:'(

any suggestions?
Thanks

Hi,

You need to autoload your module with composer.

Hello @ederrafo ,
Please have a look the following steps

1. Folder structure-

your-laravel-app/
├── app/
├── bootstrap/
├── vendor/
├── modules/
├── ├── YourModuleFolder/

2. and then check in your composer.json

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

3. run this command composer dump-autoload

Did you adjust the module - path in composer.json ?

On 12. August 2016 18:04:45 MESZ, "Eder Rafo Jose Pariona Espiñal" [email protected] wrote:

Hello @KyawNaingTun @nWidart
Thanks
Please,
When I run this command: $ php artisan module:make MyModule
the Module folder is generated out of app folder.
Why? :S
My-project/
Modules/
app/
bootstrap/
.
.

I modified the modules.php file, this line:
'modules' => base_path('app/Modules'),

That works, but I run this command again: $ php artisan module:make
OtherModule
I have this error:
[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'Modules\Frontend\Providers\MyModuleServiceProvider' not found

:'(

any suggestions?
Thanks

You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
https://github.com/nWidart/laravel-modules/issues/18#issuecomment-239487472

Diese Nachricht wurde von meinem Mobiltelefon mit Kaiten Mail gesendet.

Hi
My composer.json:

"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\": "app/",
"Modules\": "modules/"
}
}

I run : composer dump-autoload

same,
I have the same error message.

$ php artisan module:make OtherModule
Class 'Modules\Frontend\Providers\MyOtherModuleServiceProvider' not found

:(

@ederrafo
Do a full search on whole project and search for string Modules\Frontend\Providers\MyOtherModuleServiceProvider see where it is defined (autoloader, cache or somewhere else) tell us what it's linking to.

try it:

artisan module:make YourModuleName
composer dumpa

Hello guys, thanks for your answers
I solved the problem, when I generate, modules, with command $ php artisan module:make user, is generated into module User, this file modules.json in that file on line 9 :
"providers": [ "Modules\\User\\Providers\\UserServiceProvider" ],
I changed:
"providers": [ "Modules\User\Providers\UserServiceProvider" ],

Now, I generate othermodules :+1: , but always I have to edit the file modules.json :(
The error is caused by: \ , Why?
:O

Now, I run
$ composer install //for autoload files
$ php artisan route:list

Other message, similar:
[ReflectionException] Class Modules\User\Http\Controllers\UserController does not exist

:'( I'm trying to solve this

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jakecorn picture jakecorn  ·  16Comments

bashet picture bashet  ·  19Comments

bhattraideb picture bhattraideb  ·  12Comments

FoksVHox picture FoksVHox  ·  11Comments

esipavicius picture esipavicius  ·  13Comments