Learn how to deploy a Laravel-Firebase web app without the credentials json file in the code base.
- Install Laravel with
composer create-project --prefer-dist laravel/laravel [project]
- Run
composer require defuse/php-encryption kreait/firebase-php
to install the encryption library and the Firebase PHP SDK - Create folders 'app/Services/Firebase/Controllers' and 'app/Services/Firebase/Keys' to add Firebase controllers and keys
- Change the 'config/services.php' file, adding at the end:
'firebase' => [
'encryption_password' => env('FIREBASE_KEY_ENCRYPTION_PASSWORD'),
'credentials_file_url' => env('FIREBASE_CREDENTIALS_FILE_URL'),
],
- Add 'FIREBASE_KEY_ENCRYPTION_PASSWORD', 'FIREBASE_CREDENTIALS', and 'FIREBASE_CREDENTIALS_FILE_URL' to your .env file
- Run
encrypt-service-keys Firebase [credentials.json] [new_file].encrypt [encryption password]
to encrypt the Firebase credentials json file - Save the encrypted file in a public repository
- In the composer.json file, add command into 'post-autoload-dump':
"@php artisan decrypt-service-keys Firebase credentials.json"
- Create Travis .yml file
- Add 'APP_KEY', 'FIREBASE_KEY_ENCRYPTION_PASSWORD', 'FIREBASE_CREDENTIALS', and 'FIREBASE_CREDENTIALS_FILE_URL' into the environment variables
- Run tests
- Create app on Heroku
- Run
heroku buildpacks:set heroku/php
- Add 'APP_KEY', 'FIREBASE_KEY_ENCRYPTION_PASSWORD', 'FIREBASE_CREDENTIALS', and 'FIREBASE_CREDENTIALS_FILE_URL' into the environment variables
- Create Procfile
- Run
composer require --dev heroku/heroku-buildpack-php
- Link app to your GitHub repo or run
git push heroku master
This project is open-source software licensed under the MIT license.