Luminova Framework

PHP Luminova: Read and Write Firebase Realtime Database Records

Last updated: 2026-11-28 20:57:12

Select a Firebase Realtime Database path and read or replace child values with Luminova’s Firebase database wrapper.

Use Luminova\Notifications\Firebase\Database when your application stores JSON data in Firebase Realtime Database. The wrapper uses the Firebase Admin SDK for PHP. Install kreait/firebase-php and configure credentials for the PHP process before creating the wrapper. The project ID identifies the Firebase project, and the database URI comes from your Realtime Database instance. See the Firebase Admin SDK database guide.


Class Definition

  • Full namespace: Luminova\Notifications\Firebase\Database

Properties

database

The Firebase database client initialized by the constructor.

protected ?RealtimeDatabase $database = null;

RealtimeDatabase refers to Kreait\Firebase\Contract\Database.


tableName

The database path selected by setTable().

protected string $tableName;

Methods

__construct

Connect to a Firebase Realtime Database instance.

public function __construct(string $projectId, string $databaseUri)

Parameters:

ParameterTypeDescription
$projectIdstringFirebase project ID.
$databaseUristringURL of the Realtime Database instance.

setTable

Select a database path, such as profiles or accounts/profiles. Call this before reading or writing a child.

public function setTable(string $table): self

Parameters:

ParameterTypeDescription
$tablestringParent path for subsequent operations.

Return:

self - The current wrapper.


getTable

Read the selected path after calling setTable().

public function getTable(): string

Return:

string - The selected database path.


get

Read a child under the selected path.

public function get(string $child): mixed

Parameters:

ParameterTypeDescription
$childstringChild key to read.

Return:

mixed - The stored child value, or null if the child is absent.


insert

Write the supplied data to a child under the selected path. If the child already exists, this replaces its stored value.

public function insert(string $rowId, array $data): mixed

Parameters:

ParameterTypeDescription
$rowIdstringChild key to write.
$dataarray<array-key,mixed>Complete value to store at the child path.

Return:

mixed - The result of the Firebase reference write.


update

Replace the complete value at an existing or new child path. Include any fields you want to keep.

public function update(string $rowId, array $data): mixed

Parameters:

ParameterTypeDescription
$rowIdstringChild key to write.
$dataarray<array-key,mixed>Complete replacement value.

Return:

mixed - The result of the Firebase reference write.