Simple CRUD and Authentication (using Email and Password)
- Install
kreait
using composer. Example:
composer require kreait/firebase-php ^5.0
- Place the script into controller directory
App\Http\Controllers
- Change this line with your Project's Service Account (private key) and move it to controller directory
->withServiceAccount(__DIR__.'/YOUR-FIREBASE-PROJECT-adminsdk.json')
->withDatabaseUri('https://YOUR-FIREBASE-PROJECT.firebaseio.com/');
- Add some route (using GET) to access each method. Example:
Route::get('/signin', 'FirebaseController@signIn');
- Access route on your web browser. Example: http://localhost:8000/signin
{
"hewan" : {
"herbivora" : {
"domba" : "kecil",
"sapi" : "besar"
},
"karnivora" : {
"harimau" : {
"benggala" : "galak",
"sumatera" : "jinak"
}
},
"omnivora" : {
"serigala" : "galakbanget"
}
},
"tumbuhan" : {
"dikotil" : "mangga",
"monokotil" : "bambu"
}
}
- Laravel (7.x): CRUD Firebase Realtime Database: https://youtu.be/-JalSwQuTdY
- Laravel (7.x): Firebase Authentication with Email and Password: https://youtu.be/NKbvnOy5_wg
PHP
: >= 7.2Laravel
: 5.8.x (min requirement | tested on 7.25.0)kreait/clock
: 1.0.1kreait/firebase-php
: 5.7.0kreait/firebase-tokens
: 1.10.0
- Laravel (7.x) - laravel.com/docs
- Firebase Admin SDK for PHP (5.x) (< 5.15.0) - firebase-php.readthedocs.io