Skip to content
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

class 'MongoDB\Database' does not have a method 'getDoctrineDriver' #1785

Closed
fbc opened this issue Jul 26, 2019 · 12 comments
Closed

class 'MongoDB\Database' does not have a method 'getDoctrineDriver' #1785

fbc opened this issue Jul 26, 2019 · 12 comments

Comments

@fbc
Copy link

fbc commented Jul 26, 2019

When I run:

php artisan ide-helper:models

I get this error on all my models:

Exception: call_user_func_array() expects parameter 1 to be a valid callback, class 'MongoDB\Database' does not have a method 'getDoctrineDriver'
@Smolevich
Copy link
Contributor

Show more info

I install this package and run command php artisan ide-helper:models, no errors, one warning Warning: "doctrine/dbal": "~2.3" is required to load database information. Please require that in your composer.json and run composer update

@fbc
Copy link
Author

fbc commented Jul 30, 2019

for example this what the header in my user model looks like:

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Jenssegers\Mongodb\Auth\User as Authenticatable;
use Laravel\Passport\HasApiTokens;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;

class User extends Authenticatable
{
    use Notifiable, HasApiTokens;
...

here is another one:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;

class Devices extends Eloquent
{
...

@Smolevich
Copy link
Contributor

Smolevich commented Jul 30, 2019

show exception trace and problem file. I dont't understand that do you mean

@fbc
Copy link
Author

fbc commented Jul 30, 2019

show exception trace and problem file. I dont't understand that do you mean

I don't get a stack trace. I just get these errors:

$ php artisan ide-helper:models

 Do you want to overwrite the existing model files? Choose no to write to _ide_helper_models.php instead? (yes/no) [no]:
 > yes

Exception: call_user_func_array() expects parameter 1 to be a valid callback, class 'MongoDB\Database' does not have a method 'getDoctrineDriver'
Could not analyze class App\Retrofit.
Exception: call_user_func_array() expects parameter 1 to be a valid callback, class 'MongoDB\Database' does not have a method 'getDoctrineDriver'
Could not analyze class App\Utility_Meter_Readings.
Exception: call_user_func_array() expects parameter 1 to be a valid callback, class 'MongoDB\Database' does not have a method 'getDoctrineDriver'
Could not analyze class App\Dashboard.
Exception: call_user_func_array() expects parameter 1 to be a valid callback, class 'MongoDB\Database' does not have a method 'getDoctrineDriver'
Could not analyze class App\Property.
Exception: call_user_func_array() expects parameter 1 to be a valid callback, class 'MongoDB\Database' does not have a method 'getDoctrineDriver'
Could not analyze class App\User.
Exception: call_user_func_array() expects parameter 1 to be a valid callback, class 'MongoDB\Database' does not have a method 'getDoctrineDriver'
Could not analyze class App\Consumption_history.
Exception: call_user_func_array() expects parameter 1 to be a valid callback, class 'MongoDB\Database' does not have a method 'getDoctrineDriver'
Could not analyze class App\Message.
Exception: call_user_func_array() expects parameter 1 to be a valid callback, class 'MongoDB\Database' does not have a method 'getDoctrineDriver'
Could not analyze class App\Spatialviewer.
Exception: call_user_func_array() expects parameter 1 to be a valid callback, class 'MongoDB\Database' does not have a method 'getDoctrineDriver'
Could not analyze class App\Devices.
Exception: call_user_func_array() expects parameter 1 to be a valid callback, class 'MongoDB\Database' does not have a method 'getDoctrineDriver'
Could not analyze class App\AESOScraper.
Exception: call_user_func_array() expects parameter 1 to be a valid callback, class 'MongoDB\Database' does not have a method 'getDoctrineDriver'
Could not analyze class App\Custommenuitems.
Exception: call_user_func_array() expects parameter 1 to be a valid callback, class 'MongoDB\Database' does not have a method 'getDoctrineDriver'
Could not analyze class App\Notification.
Exception: call_user_func_array() expects parameter 1 to be a valid callback, class 'MongoDB\Database' does not have a method 'getDoctrineDriver'
Could not analyze class App\Profile.
Exception: call_user_func_array() expects parameter 1 to be a valid callback, class 'MongoDB\Database' does not have a method 'getDoctrineDriver'
Could not analyze class App\Audit.
Exception: call_user_func_array() expects parameter 1 to be a valid callback, class 'MongoDB\Database' does not have a method 'getDoctrineDriver'
Could not analyze class App\Chart.

@kargnas
Copy link

kargnas commented Jul 30, 2019

I am having trouble with this as well

@Smolevich
Copy link
Contributor

Show composer.json

@fbc
Copy link
Author

fbc commented Jul 30, 2019

This composer.json reads as follows:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": "^7.1.3",
        "cmgmyr/messenger": "^2.18",
        "consoletvs/charts": "6.*",
        "dmitry-ivanov/dark-sky-api": "^1.0",
        "fideloper/proxy": "^4.0",
        "intervention/image": "^2.4",
        "jenssegers/mongodb": "^3.5",
        "laravel/framework": "^5.8.0",
        "laravel/passport": "^7.0",
        "laravel/tinker": "^1.0",
        "maatwebsite/excel": "^3.1",
        "weidner/goutte": "^1.1"
    },
    "require-dev": {
        "barryvdh/laravel-debugbar": "^3.1",
        "barryvdh/laravel-ide-helper": "^2.6",
        "doctrine/dbal": "^2.9",
        "filp/whoops": "^2.0",
        "fzaninotto/faker": "^1.4",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^2.0",
        "phpunit/phpunit": "^7.0"
    },
    "autoload": {
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "scripts": {
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate"
        ],
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover"
        ]
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

@Smolevich
Copy link
Contributor

Smolevich commented Jul 31, 2019

@fbc, do you have another questions? If no, please close issue

@timoteo7
Copy link

timoteo7 commented Sep 11, 2019

When i try to generate a model with a other project,
I have the same problem trying to get information from MongoDB,
php artisan infyom:model Model --fromTable --tableName='collection'

its not a problem of this repository that i can comment the :
//Jenssegers\Mongodb\MongodbServiceProvider::class,

and the error continue

@fbc fbc closed this as completed Sep 12, 2019
@evrend
Copy link

evrend commented Aug 31, 2020

I have same problem too. I use Laravel 7 with "jenssegers/mongodb": "^4.0" package.
Edit: I added mongo models to ignored_models in ide-helper config file. Problem solved but. Ide helper does'nt work for mongo models.

@slia-stryber
Copy link

slia-stryber commented Feb 5, 2021

Exception: call_user_func_array(): Argument #1 ($callback) must be a valid callback, class MongoDB\Database does not have a method "getDoctrineDriver"
Could not analyze class App\Models\User.

Trace:
#0 /laravel/vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/Connection.php(278): call_user_func_array(Array, Array)
#1 /laravel/vendor/laravel/framework/src/Illuminate/Database/Connection.php(918): Jenssegers\Mongodb\Connection->__call('getDoctrineDriv...', Array)
#2 /laravel/vendor/laravel/framework/src/Illuminate/Database/Connection.php(901): Illuminate\Database\Connection->getDoctrineConnection()
#3 /laravel/vendor/barryvdh/laravel-ide-helper/src/Console/ModelsCommand.php(417): Illuminate\Database\Connection->getDoctrineSchemaManager()
#4 /laravel/vendor/barryvdh/laravel-ide-helper/src/Console/ModelsCommand.php(270): Barryvdh\LaravelIdeHelper\Console\ModelsCommand->getPropertiesFromTable(Object(App\Models\User))
#5 /laravel/vendor/barryvdh/laravel-ide-helper/src/Console/ModelsCommand.php(159): Barryvdh\LaravelIdeHelper\Console\ModelsCommand->generateDocs(Array, Array)
#6 /laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Barryvdh\LaravelIdeHelper\Console\ModelsCommand->handle()
#7 /laravel/vendor/laravel/framework/src/Illuminate/Container/Util.php(40): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#8 /laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure(Object(Closure))
#9 /laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#10 /laravel/vendor/laravel/framework/src/Illuminate/Container/Container.php(610): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#11 /laravel/vendor/laravel/framework/src/Illuminate/Console/Command.php(136): Illuminate\Container\Container->call(Array)
#12 /laravel/vendor/symfony/console/Command/Command.php(256): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#13 /laravel/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#14 /laravel/vendor/symfony/console/Application.php(971): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /laravel/vendor/symfony/console/Application.php(290): Symfony\Component\Console\Application->doRunCommand(Object(Barryvdh\LaravelIdeHelper\Console\ModelsCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /laravel/vendor/symfony/console/Application.php(166): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 /laravel/vendor/laravel/framework/src/Illuminate/Console/Application.php(93): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 /laravel/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 /laravel/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 {main}

@Smolevich
Copy link
Contributor

@slia-stryber don't comment closed issues, if you have a question, use discussions https://github.com/jenssegers/laravel-mongodb/discussions, if you find bug or you have proposal for feature request create new issue

@mongodb mongodb locked as off-topic and limited conversation to collaborators Feb 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants