laravel-modules icon indicating copy to clipboard operation
laravel-modules copied to clipboard

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

Open ksaif121786 opened this issue 9 months ago • 1 comments

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

ksaif121786 avatar May 13 '24 07:05 ksaif121786

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.

irvine48 avatar May 13 '24 11:05 irvine48

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

yangwenqian avatar May 17 '24 06:05 yangwenqian

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

solomon-ochepa avatar May 17 '24 19:05 solomon-ochepa

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.

solomon-ochepa avatar May 17 '24 19:05 solomon-ochepa

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.

yangwenqian avatar May 20 '24 03:05 yangwenqian

I have the same problem with v11 any solutions? image

ami-hp avatar May 28 '24 21:05 ami-hp

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 avatar May 29 '24 06:05 solomon-ochepa

Lastly, try run composer dump-autoload

solomon-ochepa avatar May 29 '24 06:05 solomon-ochepa

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

{
    "name": "nwidart/user",
    "description": "",
    "authors": [
        {
            "name": "Nicolas Widart",
            "email": "[email protected]"
        }
    ],
    "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

ami-hp avatar May 29 '24 12:05 ami-hp

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: [email protected]

solomon-ochepa avatar May 30 '24 05:05 solomon-ochepa

same error for me

yaobiao131 avatar May 30 '24 09:05 yaobiao131

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

extra

Run Command : composer dump-autoload

Mohamedalbarbary avatar Jun 03 '24 12:06 Mohamedalbarbary