Comments (5)
As far as I can see, there are actually some packages that don't quite conform to the specification. This leads to problems.
I agree. The specification says to not request dependencies in register
, as not all services have been registered at that point. If other tools ignore that, that's on them and should be reported (and fixed) there.
Another thing I don't understand is why you register through the resolving function instead of the make function.
The make
method actually resolves a dependency, which isn't what we need. We need to call the extend
method on the DatabaseManager
service to inject a custom extension for the mongodb database driver. We can't use the extend
method of the service container for this, but instead need to inject this when the db
service is resolved. The only way to achieve this is by using resolving
.
Like I said: if tools break because do what a bolded sentence in the docs tells them not to do, that's not on us, that's on them. I'm closing this as won't fix.
from laravel-mongodb.
Hello @zyz954489346, do you have any idea how we can fix this issue?
from laravel-mongodb.
Hi @zyz954489346, I believe the issue is actually in your code. Quoting from the Service Providers documentation:
Within the register method, you should only bind things into the service container. You should never attempt to register any event listeners, routes, or any other piece of functionality within the register method.
In your code, you are registering a listener, which you shouldn't be doing in register
, but rather in boot
. Again, quoting from the documentation:
So, what if we need to register a view composer within our service provider? This should be done within the boot method. This method is called after all other service providers have been registered, meaning you have access to all other services that have been registered by the framework.
from laravel-mongodb.
Hi @zyz954489346, I believe the issue is actually in your code. Quoting from the Service Providers documentation:
Within the register method, you should only bind things into the service container. You should never attempt to register any event listeners, routes, or any other piece of functionality within the register method.
In your code, you are registering a listener, which you shouldn't be doing in
register
, but rather inboot
. Again, quoting from the documentation:So, what if we need to register a view composer within our service provider? This should be done within the boot method. This method is called after all other service providers have been registered, meaning you have access to all other services that have been registered by the framework.
@alcaeus You're right, but there's no way to let other package writers to do that.
As far as I can see, there are actually some packages that don't quite conform to the specification. This leads to problems. As a user of the package, there is no other way but to override the Provider.
Another thing I don't understand is why you register through the resolving function instead of the make function. I read other similar packages, most of which are register through the make function.
from laravel-mongodb.
Hello @zyz954489346, do you have any idea how we can fix this issue?
@GromNaN I temporarily solved the problem by rewriting Provider, but this is really not an elegant solution.
from laravel-mongodb.
Related Issues (20)
- Fetching data via tinker HOT 4
- [Feature Request] Queryable Encryption or CSFLE HOT 1
- Call to undefined method MongoDB\Laravel\Query\Builder::compileWhereSub() HOT 2
- Is MongoDB support Laravel Octane (FrankenPHP server) HOT 1
- whereHas issue HOT 1
- Fatal casting issues HOT 1
- Saving/refreshing model doesn't reset `Model::$unset` HOT 3
- Need to support upsert function in Laravel 10 HOT 1
- datetime casts not considering timezone HOT 2
- Transaction already in progress HOT 7
- Connection string is missing the option to create dsn as a SRV dsn HOT 3
- First argument of MongoDB\Laravel\Query\Builder::where must be a field path as "string". Got "null" HOT 6
- seperate read, write connection not working HOT 1
- castAttribute does not handle nullable immutable date times
- DatabaseTransactions and mongodb
- [Feature Request] Cast createdAt and updatedAt field by default,that is save by mongoose HOT 2
- hasMany or hasOne doesnt work without getIdAttribute HOT 11
- Array of ObjectId not being casted to string when retrieving data HOT 1
- `whereAny` and `whereAll` query Error HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-mongodb.