1
votes

I am trying to create a new virtual development environment for one of my projects on Github. I have installed MariaDB, PHP 7, made a local clone of the repository, and restored its .env-file. It should be working.

Unfortunately, when I type php artisan and composer update, I receive the following error:

PHP Fatal error: Uncaught Error: Call to a member function connection() on null in src/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1058
Stack trace:
#0 src/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1024): Illuminate\Database\Eloquent\Model::resolveConnection(NULL)
#1 src/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(859): Illuminate\Database\Eloquent\Model->getConnection()
#2 src/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(818): Illuminate\Database\Eloquent\Model->newBaseQueryBuilder()
#3 src/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(802): Illuminate\Database\Eloquent\Model->newQueryWithoutScopes()
#4 src/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1374): Illuminate\Database\Eloquen in src/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php on line 1058

I do not know if this is relevant to the error at hand, but note the misspelling of Eloquent on stack trace #4.

You can find my composer.json file over here:
https://github.com/galadhremmin/Parf-Edhellen/blob/master/src/composer.json

PHP version: 7.1.2 on Debian 9.

Any ideas what might be wrong?

Edit This affects the artisan and composer components which won't even run.

1
Is MariaDB (the MySQL service) actually turned on? Just because you installed it doesn't mean it's on. - Brian Gottier
@BrianGottier I believe it is, as it does respond when I type mysql in the terminal. I can log in, and query the database with the credentials provided in the .env-file. - Leonard
Look at this file: src/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php line number 1058, whatever instance of a class is in front of the connection() method has not been instantiated. - KIKO Software
and of course you've double checked your connection settings at least twice ... so I'd try to connect with a plain PHP script and debug that. I'm just talking about mysqli functions or PDO. - Brian Gottier
Sounds Laravel specific then. I've used Laravel a few times in the past, but not qualified to give you help here. - Brian Gottier

1 Answers

3
votes

I have found the root of the issue by using debug_print_backtrace. It is an excellent method which prints a full back-trace.

The issue in this case was the fact that I had attached a logging service to the exception handler. The logger would reach out to a database in order to record the error that occurred, and it did not support the CLI environment.