问题
First sorry for bad english, not native.
I'v an Laravel 5.3 App running on XAMPP, windows 7 machine.
Everything was working great, and i don't have made any impact changes on code, it just happened.
Everytime my app trys to build the connection with mysql this error is shown:
FatalThrowableError in ConnectionFactory.php line 237:
Illegal offset type
in ConnectionFactory.php line 237
ConnectionFactory->createConnector(array('driver' => 'mysql', 'host' => '127.0.0.1', 'port' => '3306', 'database' => 'megaboff', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => true, 'engine' => null, 'name' => 'mysql')) in ConnectionFactory.php line 126
at ConnectionFactory->Illuminate\Database\Connectors\{closure}()
at call_user_func(object(Closure)) in Connection.php line 965
at Connection->getPdo() in Connection.php line 986
at Connection->getReadPdo() in Connection.php line 423
at Connection->getPdoForSelect(true) in Connection.php line 333
I can use tinker to access my app and data in the database. It only don't work in browser.
Any query to the database via browser this same error occurs. I did not change database config or env file. Here is the array:
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'megaboff'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
I would likely provide you more info as you seem it's needed, because now i don't have a clue why this is happening.
Thanks in advance, Pedro
回答1:
Try the command "php artisan config:cache" or "php artisan config:clear". Can try too set your database configuration in the file .env.
回答2:
I had the same problem and tried two solutions but i'm not sure wich one worked:
First i did a "php artisan config:clear" as suggested by Paulo Costa because yesterday i did the config:cache, but the problem was still here.
Secondly i did a restart of WAMP (as suggested Roy Trenneman ;) ) and it worked.
So i'm not sure if both helped of just the restart.
Bonus : https://www.youtube.com/watch?v=5UT8RkSmN4k
来源:https://stackoverflow.com/questions/41769592/illegal-offset-type-laravel-5-3-connectionfactory-php-every-model