nWidart / laravel-modules

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

Class "Modules\Admin\Providers\AdminServiceProvider" not found #1856

Closed ksaif121786 closed 3 months ago

ksaif121786 commented 4 months ago

showing me this Class "Modules\Admin\Providers\AdminServiceProvider" not found and composer dump-autoload not working

irvine48 commented 4 months ago

https://github.com/nWidart/laravel-modules?tab=readme-ov-file#autoloading

try to update this part, i successful solve this issue on my latest pull.

yangwenqian commented 4 months ago

I have encountered the same situation with laravel 11. Have you resolved it? my step: 1.laravel new website (v11) & artisan migrate 2.composer require nwidart/laravel-modules & vendor:publish 3.update extra in composer.json 12 4.composer dump-autoload 5.php artisan module:make Blog then: Class "Modules\Blog\Providers\BlogServiceProvider" not found 13

solomon-ochepa commented 4 months ago

Can you share a screenshot of your module's composer.json, module.json and the provider class?

solomon-ochepa commented 4 months ago

I have encountered the same situation with laravel 11. Have you resolved it?

my step:

  1. laravel new website (v11) & artisan migrate
  2. composer require nwidart/laravel-modules & vendor:publish
  3. update extra in composer.json 12 ...

Your main composer.json file is okay.

yangwenqian commented 4 months ago

Can you share a screenshot of your module's composer.json, module.json and the provider class?

It is currently running normally, it is my own problem. opcache setting error. thanks.

ami-hp commented 3 months ago

I have the same problem with v11 any solutions? image

solomon-ochepa commented 3 months ago

I have the same problem with v11 any solutions? image

Check your module composer.json, module.json and the Service Provider itself. Compare the value of the namespace in each of the files.

solomon-ochepa commented 3 months ago

Lastly, try run composer dump-autoload

ami-hp commented 3 months ago

@solomon-ochepa i ran composer dump-autoload modules composer :

{
    "name": "nwidart/user",
    "description": "",
    "authors": [
        {
            "name": "Nicolas Widart",
            "email": "n.widart@gmail.com"
        }
    ],
    "extra": {
        "laravel": {
            "providers": [],
            "aliases": {

            }
        }
    },
    "autoload": {
        "psr-4": {
            "Modules\\User\\": "app/",
            "Modules\\User\\Database\\Factories\\": "database/factories/",
            "Modules\\User\\Database\\Seeders\\": "database/seeders/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Modules\\User\\Tests\\": "tests/"
        }
    }
}

module.json:

{
    "name": "User",
    "alias": "user",
    "description": "",
    "keywords": [],
    "priority": 0,
    "providers": [
        "Modules\\User\\Providers\\UserServiceProvider"
    ],
    "files": []
}

i even added psr-4 to composer to make sure and ran it all again. image

by the way this is out of the box and according to documentation. didn't change anything yet

solomon-ochepa commented 3 months ago

Could you remove the addition at line 30 from the module's composer.json (image above)?

Please ensure the main composer.json doesn't include the modules in its autoload.psr-4 section.

If the problem persists, please feel free to reach out for direct support. To assist you effectively, I would need limited access to your code.

WhatsApp: https://wa.me/2348162682618, Telegram: https://t.me/solomon_ochepa, Email: solomonochepa@gmail.com

yaobiao131 commented 3 months ago

same error for me

Mohamedalbarbary commented 3 months ago

To Fix This Issue Please update extra in composer.json :

extra

Run Command : composer dump-autoload