Closed koAndy closed 5 years ago
Hey @koAndy, do you have a full stack trace?
From memory, I think I've seen that error when using the RefreshDatabase trait when testing. And just from having a quick scan, it looks like there are only a few places that you might receive that error. Are you using the database as your session driver?
Hi, thanks for quick answer. I do not use any testing. Just want to create an API and stated with login using Laravel Passport.
First, when tried the setup, I had this error on any request made in api.php but removing throttle from app/Http\Kernel.php ('throttle:60,1') made things work nicely.
Now the error appears when a request is made on http://localhost/oauth/token, even without any parameters sent to POST request with POSTMAN.
The stacktrace is this:
Symfony\Component\Debug\Exception\FatalThrowableError: Call to a member function beginTransaction() on null in file /Users/user/PHP-Projects/myproject/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php on line 108 Stack trace:
Maybe oauth has some throttling, too?
And, yes, the sessions are in database too, but switching back to 'file' results in same error mentioned above.
Does your User
class extend DesignMyNight\Mongodb\Auth\User
? It sounds like you have something that isn't routing your code your code properlty. Please double check you have followed the instructions in
https://github.com/jenssegers/laravel-mongodb#installation https://github.com/jenssegers/laravel-mongodb#configuration https://github.com/jenssegers/laravel-mongodb#configuration https://laravel.com/docs/master/passport#installation
If your using https://github.com/jenssegers/laravel-mongodb, the database session driver isn't supported without this package https://github.com/jenssegers/Laravel-MongoDB-Session, in the meantime i would suggest reverting to the file driver.
I have managed to make it work.
Removed middleware throttle from routeRegistrar.php from vendor/Laravel/passport made the trick.
Session seems to not have any problem.
Thanks!
Glad you managed to fix it! Out of curiosity, are you using the database as your cache driver?
Yes, cache driver in database also. And guess what? I have put the throttle back in Kernel and RouteRegistrar as originally was, and put CACHE_DRIVER in file mode and everything works as it should.
So it seems that CACHE_DRIVER=database causes the problem.
Thanks a lot for the tip!
Do you have any advice to make it work with CACHE_DRIVER in database mode and without removing throttle from those two files?
in config/app.php
Try setting the connection to mongodb under database EDIT
'stores' => [
'apc' => [
'driver' => 'apc',
],
'array' => [
'driver' => 'array',
],
'database' => [
'driver' => 'database',
'table' => 'cache',
'connection' => 'mongodb', <--------
],
I think you wanted to say config/cache.php Anyway not working. After setting mongodb returns: "Driver [mongodb] is not supported."
Sorry, yes i meant config/cache.php, but also meant connection, not driver.
Nop, changing connection from null to mongodb
returns Call to a member function beginTransaction() on null
as stated at the begging of this issue.
Sounds like https://github.com/jenssegers/laravel-mongodb doesn't work as a database cache driver then. Sorry, i'm out of ideas without looking into it further.
Ok, staying on file CACHE_DRIVER for the moment. Thanks!
I'm using Laravel 5.6 and Passport 7.0 with Jenssengers MongoDB. Installation of passport when very well, including migrations. Every collection exists. I have two records in oauth_clients collections. I have created a new user in users collection.
Trying to login my user through oauth/token, generate this error: Call to a member function beginTransaction() on null in file laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php on line 108
Any advice?