Skip to content

Use laravel-mongodb outside laravel/lumen #1037

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

Closed
alex-arhat opened this issue Nov 18, 2016 · 1 comment
Closed

Use laravel-mongodb outside laravel/lumen #1037

alex-arhat opened this issue Nov 18, 2016 · 1 comment

Comments

@alex-arhat
Copy link

alex-arhat commented Nov 18, 2016

unfortunately use laravel-mongodb outside laravel require global function app() like this

function app() {
    return new class() {
        public function version() {
            return '5.3';
        }
    };
}

cause in .../jenssegers/mongodb/src/Jenssegers/Mongodb/Query/Builder function shouldUseCollections() is

    /**
     * Returns true if Laravel or Lumen >= 5.3
     *
     * @return bool
     */
    protected function shouldUseCollections()
    {
        if (function_exists('app')) {
            $version = app()->version();
            $version = filter_var(explode(')', $version)[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); // lumen
            return version_compare($version, '5.3', '>=');
        }
    }

if any other way to detect version of Illuminate\database that free app() function?

@wedgwood
Copy link

it seems the root cause of #955

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants