{"id":19,"date":"2021-01-14T07:36:35","date_gmt":"2021-01-14T07:36:35","guid":{"rendered":"https:\/\/mouryasolutions.in\/blog\/?p=19"},"modified":"2023-01-29T18:24:26","modified_gmt":"2023-01-29T18:24:26","slug":"firebase-connection-in-laravel","status":"publish","type":"post","link":"https:\/\/mouryasolutions.in\/blog\/firebase-connection-in-laravel\/","title":{"rendered":"How to make DB connection with firebase in Laravel"},"content":{"rendered":"<div class=\"post-content\">\n<blockquote class=\"wp-block-quote\">\n<p>To connect to Firebase Realtime Database in Laravel, you can use the official Firebase PHP SDK. Here is an example of how to connect to Firebase Realtime Database in Laravel:<\/p>\n<\/blockquote>\n\n\n\n<h4>First, install the Firebase PHP SDK:<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>composer require firebase\/php-jwt\r\ncomposer require kreait\/firebase-php\r<\/code><\/pre>\n\n\n\n<h4>Next, you can use the following code to connect to Firebase Realtime Database:<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>use Kreait\\Firebase\\Factory;\r\nuse Kreait\\Firebase\\ServiceAccount;\r\n\r\n$serviceAccount = ServiceAccount::fromJsonFile(__DIR__.'\/service-account.json');\r\n$firebase = (new Factory)\r\n    ->withServiceAccount($serviceAccount)\r\n    ->create();\r\n\r\n$database = $firebase->getDatabase();\r\n<\/code><\/pre>\n\n\n\n<p>Note: Replace <code>service-account.json<\/code> with the path to your Firebase Service Account JSON file.<\/p>\n\n\n\n<p>Once you have connected to Firebase Realtime Database, you can perform various operations, such as reading and writing data, using the provided Firebase API.<\/p>\n<\/div><!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>To connect to Firebase Realtime Database in Laravel, you can<a href=\"https:\/\/mouryasolutions.in\/blog\/firebase-connection-in-laravel\/\">Read More<i class=\"fa fa-long-arrow-right\" aria-hidden=\"true\"><\/i><\/a><!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/posts\/19"}],"collection":[{"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/comments?post=19"}],"version-history":[{"count":4,"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/posts\/19\/revisions"}],"predecessor-version":[{"id":484,"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/posts\/19\/revisions\/484"}],"wp:attachment":[{"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/media?parent=19"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/categories?post=19"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/tags?post=19"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}