Configuration
All configuration settings can be found in the firebase.php file, which is located in the config directory under config/firebase.php
.
If the file does not exists, you need to run the following artisan command:
php artisan vendor:publish --provider="Kreait\Laravel\Firebase\ServiceProvider" --tag=config
Guest Url
To modify the URL to which a user is redirected when attempting to access routes with the f.guest
middleware after logging in, navigate to the config/firebase.php
file and update the guest_url
value. The default setting is home
.
Auth Url
To modify the URL to which a user is redirected when attempting to access routes with the f.auth
middleware after logging out, navigate to the config/firebase.php
file and update the auth_url
value. The default setting is login
.
Auth Model
To modify the model used for authentication, navigate to the config/firebase.php
file and update the auth_model
value. The default setting is App\\FModels\\User
. Adjust it to the appropriate model for authentication.
Ensure that the specified model exists, or you can create it using the following artisan command:
php artisan make:fmodel User
See more about FModels Artisan Commands.
Class Namespace
To alter the location or class namespace for the creation of models, navigate to the config/firebase.php
file and modify the class_namespace
to the desired namespace or location.
Note that models are generated in the location based on the specified namespace provided. For example, if the namespace is set to App\\FModels\\
, the models will be created in the app/FModels
directory.
The default setting is App\\FModels
.
Firebase Credentials
To obtain the firebase-credentials.json file for Cloud Firestore and set it up with you project, you need to follow these steps:
- Go to the Firebase Console and create a new project.
- Click on the Project Overview button.
- Click on the Settings button and select Project Settings.
- Click on the Service Accounts tab.
- Click on the Generate New Private Key button to download the firebase-credentials.json file.
- Copy firebase-credentials.json to Your Project.
- Update .env File with the following
- Open your .env file and add the following line, replacing
path/to/firebase-credentials.json
with the correct path:
FIREBASE_CREDENTIALS=/path/to/firebase-credentials.json
Now your Laravel project is configured to use the Firebase credentials for Cloud Firestore. Make sure to keep the firebase-credentials.json file secure and not expose it publicly.
Firebase Project Id
To obtain the Firebase Project Id, you need to follow these steps:
- Go to the Firebase Console and select your project.
- Click on the Project Overview button.
- Click on the Settings button and select Project Settings.
- Copy the Project ID.
- Update .env File with the following:
- Open your .env file and add the following line, replacing
your-project-id
with the correct project id:
FIREBASE_PROJECT_ID=your-project-id
The Project ID is a unique identifier for your Firebase project. You can use this Project ID when configuring Firebase services or integrating Firebase with other platforms.
Firebase Database Url
To obtain the Firebase Database Url, you need to follow these steps:
- Go to the Firebase Console and select your project.
- Click on the Project Overview button.
- Click on the Settings button and select Project Settings.
- Click on the Service Accounts tab.
- Copy the Database URL. It should look something like this:
https://<your-project>.firebaseio.com
. - Update .env File with the following:
- Open your .env file and add the following line, replacing
https://<your-project>.firebaseio.com
with the correct database url:
FIREBASE_DATABASE_URL=https://<your-project>.firebaseio.com
You can copy this URL and use it in your Laravel application's configuration, particularly if you are working with Firebase Realtime Database features.