gsposato / yii2-firestore

A Yii2 Component that connects to Google Firestore
MIT License
3 stars 0 forks source link

firebase_auth.json #3

Open asifrafeeq opened 5 years ago

asifrafeeq commented 5 years ago

hello dear, thanks a lot for making such a nice extension for firebase with yii2, I have a question that where should I keep or create the firebase_auth.json and what should be the credentials I have the following credentials. should I add these credentials in firebase_auth.json ?

Please define more. thanks a lot in advance.

<script src="https://www.gstatic.com/firebasejs/5.8.3/firebase.js"></script>
<script>
  // Initialize Firebase
  var config = {
    apiKey: "",
    authDomain: "",
    databaseURL: "",
    projectId: "",
    storageBucket: "",
    messagingSenderId: ""
  };
  firebase.initializeApp(config);
</script>
gsposato commented 5 years ago

It looks like you are using firestore with javascript. If that is the case you may not need my plugin in the first place, as it is designed to be used with backend php functions in a yii2 framework.

if you will need to use firestore functions directly in the php side of your application, you will first need to find where main.php is located in yii2. Unlike other frameworks, yii2 has multiple templates, so the location of main.php varies depending on what template you used. A lot of developers use the Advanced App Template for yii2, so their main.php would be here: /webroot/common/config/main.php. More information about that is here: https://www.yiiframework.com/doc/guide/2.0/en/concept-configurations

Inside main.php, you define where firebase_auth.json is located on your server. So it can be anywhere:

'firestore' => [ 'class' => 'vendor\gsposato\yii2firestore\FirestoreComponent', 'credential_file'=>'/path/to/your/firebase_auth.json', 'project' => 'your-project-name', ],

Best server practices are to put any sort of keys (like firebase_auth.json) where the public cannot access them by typing in a url such as http:://yourserver.com/secret/firebase_auth.json

If you are using a Linux/Unix type server, you can create a directory /etc/firebase/ and put it there. On Windows, something like C:\firebase\ should be fine.