-
-
Notifications
You must be signed in to change notification settings - Fork 991
ModuleServiceProvider register singleton issue #1761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
thanks for the detailed post, this will help me to dig into it further |
I had a similar problem when upgrading one of the dependencies. I solved it by locking the dependency to the previous working version. You can check out the issue here: GitHub Issue #109. I hope this will help you. |
Error Class "Modules\Blog\Providers\BlogServiceProvider" not found I even deleted the module but still facing this |
Have you tried remove the line "Blog" : true from module_statuses.json file and run |
I copied so backends and frontend s and reinstalled Laravel-module package
but now everything is good
…On Thu, 6 Mar 2025, 9:42 am Sunwarul Islam, ***@***.***> wrote:
Error
Class "Modules\Blog\Providers\BlogServiceProvider" not found I even
deleted the module but still facing this
Have you tried remove the line "Blog" : true from module_statuses.json
file and run composer dump-autoload ?
—
Reply to this email directly, view it on GitHub
<#1761 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ARHBH477VDDEOTBYTS7KJSL2S7U5BAVCNFSM6AAAAABEVNUEPWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMBSHE2DONZXGE>
.
You are receiving this because you commented.Message ID:
***@***.***>
[image: Sunwarul]*Sunwarul* left a comment (nWidart/laravel-modules#1761)
<#1761 (comment)>
Error
Class "Modules\Blog\Providers\BlogServiceProvider" not found I even
deleted the module but still facing this
Have you tried remove the line "Blog" : true from module_statuses.json
file and run composer dump-autoload ?
—
Reply to this email directly, view it on GitHub
<#1761 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ARHBH477VDDEOTBYTS7KJSL2S7U5BAVCNFSM6AAAAABEVNUEPWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMBSHE2DONZXGE>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I faced the same issue on Laravel 12. After a clean installation and adding a module, I got this error :
|
Make sure you have this in your laravel main composer.json
|
Thanks it works |
I am having a weird issue with one of my Module service providers.
In the register method of my ModuleServiceProvider I have this code
My ModifiedGate class has the
Conditionable
trait.In one of my codes I am using the conditionable when method on the Gate Facade like this.
Now, before I updated to Laravel 10, everything worked perfectly. However after upgrading to Laravel 10, I am having an issue with the when method. I get this error
Call to undefined method Illuminate\Auth\Access\Gate::when()
.After hours of debugging I believe that the singleton bind in my ModuleServiceProvider is somehow not working. What is weird though is that I can verify that the code is being run. If I place a dd() inside the singleton bind, or before it, my code hits it. That tells me that at least Laravel is running the code to bind it. But it somehow does not stick as Laravel still resolves the original GateContract instead of my ModifiedGate.
After debugging further, I noticed that if I place the bind code in the register method of the default AppServiceProvider class, everything works fine. That means Laravel properly binds the singleton from the default AppServiceProvider class.
Another weird observation is this. If I manually add my ModuleServiceProvider class into the providers array of the app config file like the example below, it also works perfectly. Laravel recognises the singleton bind.
This is weird because I thought Laravel auto-discovered Module ServiceProviders and there should be no need to manually register them. The fact that Laravel executes the singleton bind code even without the manual registration suggests to me that that is the case, so I can't figure out why I need the manual registration before Laravel accepts the singleton bind.
I have cleared the compiled files in bootstrap/cache folder. I have tried running artisan compile (and curious enough the ModuleServiceProviders are not listed in the compiled providers array🤔). I have tried adding the service provider to the extra laravel key of the Modules composer.json file (to force Laravel to auto-discover it). I have also tried removing it. All to no avail.
The only thing that works for now is doing the binding in the AppServiceProvider's register method, or keeping the code in my ModuleServiceProvider and manually registering my ModuleServiceProvider in app config providers array.
Any ideas what I could be doing wrong? If it will help, I can provide a link to the flareapp.io error.
Thank you for your time.
The text was updated successfully, but these errors were encountered: