Connecting To Firestore Using Laravel 6 Not Working

Tags: , , , ,

I’ve been trying to insert data into firestore using my laravel 6 application and it looks like its trying to connect to mysql.

I’ve tried to remove the db part in my .env file:


But it doesnt seem to work. First off this is the error am getting when i try to insert:

"message": "SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO)

This is my php code:


namespace AppHttpControllers;

use IlluminateHttpRequest;
use GoogleCloudFirestoreFirestoreClient;
use GoogleCloudFirestoreFireStoreDocument;

class LogisticsController extends Controller

    public $firestoreClient;

     * __construct initialize firestore client
     * @return void
    public function __construct()

        $this->firestoreClient = new FirestoreClient([
            'projectId' => 'my-project-id',


     * create  a new logistics company
     * @return 
    protected function create(Request $request)

        //get and validate form data
        $validatedData = $request->validate([
            'company_name' => 'required|unique:company_name|max:255',
            'registration_no' => 'required'

        $company_name = $request->company_name;
        $registration_no = $request->registration_no;

        $this->firestoreClient->addDocument('Logistics_Companies', [
            'company_name' =>  $company_name,
            'registration_no' => $registration_no,
            'created_at' => new FirestoreTimestamp,
            'updated_at' => '',
            'deleted_at' => ''  

I dont know why its trying to connect using mysql. Anyone know what i need to do or what am doing wrong ???.

Every form of help is highly appreciated. Cheers!!!!


The env file is only used to override the default database defined in the config/databases.php file, within that file you’ll need to modify this line if you don’t want to use mysql:

'default' => env('DB_CONNECTION', 'mysql')

However, since it’s trying to connect to a mysql database, somewhere in your project you’re using Laravel’s orm (eloquent) and will need to integrate Firestore at a deeper level into Laravel or refrain from using Eloquent.

Source: stackoverflow