PHPackages                             everth/laravel-firebase-models - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. everth/laravel-firebase-models

ActiveLibrary[Database &amp; ORM](/categories/database)

everth/laravel-firebase-models
==============================

399PHP

Since Oct 9Pushed 1y ago1 watchersCompare

[ Source](https://github.com/EverthSarantes/laravel-firebase-models)[ Packagist](https://packagist.org/packages/everth/laravel-firebase-models)[ RSS](/packages/everth-laravel-firebase-models/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Firebase Models
=======================

[](#laravel-firebase-models)

`Laravel Firebase Models` is a package that allows you to seamlessly interact with Firebase Realtime Database in a Laravel project, using Eloquent-like models. This package abstracts the Firebase API into an intuitive interface for creating, reading, updating, and deleting records, along with relations similar to the ones in Laravel's ORM.

Features
--------

[](#features)

- Eloquent-style models for Firebase Realtime Database.
- CRUD operations (Create, Read, Update, Delete) via Firebase.
- Simple relationships like `belongsToOne` and `hasMany` for handling related data.
- Command to generate Firebase models quickly.
- Firebase authentication with session management.

Installation
------------

[](#installation)

### 1. Install via Composer

[](#1-install-via-composer)

In your Laravel project directory, run the following command to install the package:

```
composer require everth/laravel-firebase-models dev-main
```

### 2. Set Firebase Credentials

[](#2-set-firebase-credentials)

Update your `.env` file with your Firebase credentials:

```
FIREBASE_CREDENTIALS=/path/to/your/firebase_credentials.json
FIREBASE_DATABASE_URL=https://your-database-url.firebaseio.com
```

Ensure that the path to your Firebase credentials JSON file is correct, and replace the `FIREBASE_DATABASE_URL` with your Firebase project's Realtime Database URL.

Usage
-----

[](#usage)

### Generating a Firebase Model

[](#generating-a-firebase-model)

To generate a new Firebase model, use the provided Artisan command:

```
php artisan make:firebaseModel ModelName
```

This will create a new model in the `app/Models/Firebase` directory. You can specify the Firebase collection by setting the `$collection` property in the model.

Example:

```
