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

Fatal error: Uncaught Error: Class 'Illuminate\Foundation\Application' not found #944

Closed
ghost opened this issue Sep 6, 2016 · 9 comments

Comments

@ghost
Copy link

ghost commented Sep 6, 2016

Hi,

Earlier I was using dev-master branch which was supporting new MongoDB drivers. Recently i updated it to 3.1-alpha and 3.0 version but am getting this Uncaught Error for class 'Illuminate\Foundation\Application'. Before update this was working fine and now its breaking entire thing. I am using this outside laravel framework.

Fatal error: Uncaught Error: Class 'Illuminate\Foundation\Application' not found in /var/www/jetmetrix_new/vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/Query/Builder.php:99 Stack trace: #0 /var/www/jetmetrix_new/vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/Eloquent/Model.php(536): Jenssegers\Mongodb\Query\Builder->__construct(Object(Jenssegers\Mongodb\Connection), Object(Jenssegers\Mongodb\Query\Processor)) #1 /var/www/jetmetrix_new/vendor/illuminate/database/Eloquent/Model.php(1831): Jenssegers\Mongodb\Eloquent\Model->newBaseQueryBuilder() #2 /var/www/jetmetrix_new/vendor/illuminate/database/Eloquent/Model.php(1801): Illuminate\Database\Eloquent\Model->newQueryWithoutScopes() #3 /var/www/jetmetrix_new/vendor/illuminate/database/Eloquent/Model.php(3513): Illuminate\Database\Eloquent\Model->newQuery() #4 /var/www/jetmetrix_new/vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/Eloquent/Model.php(553): Illuminate\Database\Eloquent\Model->__call('where', Array) #5 /var/www/jetmetrix_new/lib/JetMetrix.php(3926): Jensseg in /var/www/jetmetrix_new/vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/Query/Builder.php on line 99

@acidjazz
Copy link

acidjazz commented Sep 14, 2016

same here

temporary fix until things are resolved in Builder.php line 94:

    /**
     * Create a new query builder instance.
     *
     * @param Connection $connection
     * @param Processor  $processor
     */
    public function __construct(Connection $connection, Processor $processor)
    {
        $this->grammar = new Grammar;
        $this->connection = $connection;
        $this->processor = $processor;
        //$this->useCollections = version_compare(\Illuminate\Foundation\Application::VERSION, '5.3', '>=');
        $this->useCollections = true;
    }

@acidjazz
Copy link

if it helps speed things up @jenssegers it looks like instead of that constant there is a an $app->version() function for Lumen (which is what I'm using)

@ghost
Copy link
Author

ghost commented Sep 14, 2016

@acidjazz @jenssegers when using this outside laravel framework, the version compare of laravel framework is not required so it's best to put inside a condition

if (class_exists('\\Illuminate\\Foundation\\Application')) {
    $this->useCollections = version_compare(\Illuminate\Foundation\Application::VERSION, '5.3', '>=');
} else {
    $this->useCollections = true;
}

@acidjazz
Copy link

@JetSynthesys thanks, why is that though? why does returning collections only exist in 5.3 now but in Lumen it was always OK?

@acidjazz
Copy link

It looks like PR #948 seems to address this, if you look at the addition

@GreenLamantin
Copy link

GreenLamantin commented Sep 15, 2016

For Lumen you can add to your bootstrap next rows as temporary solution:

if (!class_exists('\Illuminate\Foundation\Application')) {
    class_alias(\App\Application::class, '\Illuminate\Foundation\Application');
}

Create Application class in app directory or specify another class instead \App\Application and add:

const VERSION = "5.3";

@acidjazz
Copy link

@GreenLamantin I would say @morrislaptop 's change is the most sound in #948 so far since he's still actually checking for the version

@giaule
Copy link

giaule commented Sep 23, 2016

@GreenLamantin i had try used your idea, this good

Thanks.

@petidesoftwares
Copy link

i need help on the following issue:
Fatal error: Uncaught Error: Class 'Illuminate\Foundation\Application' not found in
C:\Users\DELL\Documents\GitHub\arms-backend\bootstrap\app.php:14
Stack trace:
#0 C:\Users\DELL\Documents\GitHub\arms-backend\public\index.php(38): require_once()
#1 C:\Users\DELL\Documents\GitHub\arms-backend\server.php(21): require_once('C:\Users\DELL\D...')
#2 {main}
thrown in C:\Users\DELL\Documents\GitHub\arms-backend\bootstrap\app.php on line 14

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

5 participants