Complete BLoC with Clean Architecture (group chat) Discount !! E-commerce App With Backend Source Code Video and Voice Chatting App Firebase Chatting App Source Code Complete Gym App BLoC State Management Source Code Complete Study App Buy Ticket Booking App Source Code Buy Travel App With Backend Source Code Complete Chat App Udemy Course Special Offer Discount !! Online Learning Course App (BLoC) Online Learning Course App (Riverpod) Online Learning Course App (Getx) Discount !! Shopping App (Provider) Cool Flutter Game Flutter Nodejs Chat App Flutter Nodejs Api And Firebase Chat App Riverpod Task Management App
Here we will see how to integrate Firebase service for
PHP Laravel Framework for sending notification.
In order to access a Firebase project and its related services using a server SDK, requests must be authenticated. For server-to-server communication this is done with a Service Account.
The package uses auto discovery for the default project to find the credentials needed for authenticating requests to the Firebase APIs by inspecting certain environment variables and looking into Google's well known path(s).
Install & Publish
You need to get the package by running the following commnad. It would install PHP Laravel package for Firebase communication.
composer require kreait/laravel-firebase
Once this is done, you need to publish the package so that, Laravel framework can find it and use it.
# Laravel php artisan vendor:publish --provider="Kreait\Laravel\Firebase\ServiceProvider" --tag=config
Firebase Admin SDK
Now let's really install the Firebase Admin SDK in your app. First you have to get the SDK from Firebase console.
Service accounts tab and then click on
Generate new private key Then put the downloaded JSON file into your project root folder.
Configure .env File
Now it's time to configure our
.env file. There are two things to configure in the .env file. I need to add the below two items in .env file.
To get FIREBASE_DATABASE_URL go to firebase console and get the project ID. See the picture below
# You can find the database URL for your project at # https://console.firebase.google.com/project/_/database FIREBASE_DATABASE_URL=https://<your-project>.firebaseio.com
your-project you need to put your project ID from firebase.
And after that we need to add FIREBASE_CREDENTIALS. For this one we just need to add the file name that we downloaded from firebase console. That's it.