Illegal offset type - Laravel 5.3 - ConnectionFactory.php - Every Model
Asked Answered
F

2

2

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

Firedrake answered 20/1, 2017 at 17:49 Comment(2)
Are you using php artisan serve to run your app? If yes, restart php artisan serve. It should be restarted to reflect the changes in env fileSickness
i'm not using php artisan serve to run app. I'v xampp configured with vhosts. thanks for your reply.Firedrake
U
0

Try the command "php artisan config:cache" or "php artisan config:clear". Can try too set your database configuration in the file .env.

Ulcerate answered 20/1, 2017 at 18:35 Comment(1)
@PedroX Have you tried leaving only the .env variables in your database.php configuration? Type like this: env ('DB_HOST'), env ('DB_DATABASE') ... And just set values in .envUlcerate
A
1

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

Ahasuerus answered 24/1, 2017 at 9:50 Comment(0)
U
0

Try the command "php artisan config:cache" or "php artisan config:clear". Can try too set your database configuration in the file .env.

Ulcerate answered 20/1, 2017 at 18:35 Comment(1)
@PedroX Have you tried leaving only the .env variables in your database.php configuration? Type like this: env ('DB_HOST'), env ('DB_DATABASE') ... And just set values in .envUlcerate

© 2022 - 2024 — McMap. All rights reserved.