spatie / laravel-ray

Debug with Ray to fix problems faster in Laravel apps
https://myray.app
MIT License
291 stars 64 forks source link

Getting a "Database connection [mysql] not configured" error #177

Closed ghost closed 3 years ago

ghost commented 3 years ago

When attempting to install the laravel-ray package, I get this error: "Database connection [mysql] not configured". This is presumably because I don't actually have a connection named "mysql" in config/database.php.

There is a simple workaround for me: if I simply copy and paste of one of my other connections arrays in database.php, and rename the copy to "mysql", the laravel-ray package installs and works just fine. But having to have the extra array in databases.php that does nothing except allow me to use Ray seems like a bug? If not a bug, then an inconvenience?

Versions

Ray version: 1.14.7.0 spatie/ray package version: 1.17.1 spatie/laravel-ray package version: 1.21.2 PHP version: 7.4.8 Laravel version: 8.35.1

To Reproduce

  1. Rename the 'mysql' array in config/database.php to 'mysql-test'
  2. Rename any references to the 'mysql' connection in the app to 'mysql-test'
  3. Attempt to install laravel-ray

Expected behavior

I would expect laravel-ray to install and work without the existence of a config/database.php connection named 'mysql'

Desktop (please complete the following information):

This is not a showstopping bug at all! It's just unexpected and a minor inconvenience. But I thought it was worth reporting.

freekmurze commented 3 years ago

Could you post the error that you saw (maybe use "Share" on the exception page, and paste the link here)

ghost commented 3 years ago

Sure. Here you go: https://flareapp.io/share/W7zljavm#F20

RomkaLTU commented 3 years ago

Similar issue here, in our project we even dont use any Database, but getting "Database (homestead) does not exist. (SQL: PRAGMA foreign_keys = ON;)" after Ray install.

b166er commented 3 years ago

in my case i found a solution for exact same problem, i use multiple-database connections without default "mysql"-connection! in my config/queue.php at last lines i found this default content:

'failed' => [
        'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
        'database' => env('DB_CONNECTION', 'mysql'), // <-- here is not configured named connection
        'table' => 'failed_jobs',
    ],

the error is sometimes shown in my batch jobs when failed jobs appear. i just fixed this config with my correct database-connection-name.

just a hint, search for missing connection-names in /config and /app folder

tux3d0 commented 2 years ago

What I did was go to config/database.php copied my mysql DB connection info, pasted it below it and renmaed that section.

I could have just renamed the mysql driver section to system, but im only playing with it right now and being lazy,.

Polfo commented 1 year ago

In my case php artisan config:clear solved the issue

sudesh-rd commented 4 months ago

In my case, I could not even run php artisan config:clear, without getting error.

Deleting bootstrap\cache\config.php file solved the issue