PHP code example of giginc / cakephp3-driver-cloud-firestore
1. Go to this page and download the library: Download giginc/cakephp3-driver-cloud-firestore library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
giginc / cakephp3-driver-cloud-firestore example snippets
'Datasources' => [
...
'cloud-firestore' => [
'className' => 'Giginc\CloudFirestore\Database\Connection',
'driver' => 'Giginc\CloudFirestore\Database\Driver\CloudFirestore',
'projectId' => env('CLOUD_FIRESTORE_PROJECT_ID', 'project_id'),
'keyFile' => [], // Console. Ex: json_decode(file_get_contents($path), true).
'keyFilePath' => null, //The full path to your service account credentials .json file retrieved.
'retries' => 3,
],
],
//src/Model/Table/ProductsTable.php
namespace App\Model\Table;
use Giginc\CloudFirestore\ORM\Table;
/**
* ProductsTable Table
*
* @uses Table
* @package Table
*/
class ProductsTable extends Table
{
public function initialize(array $config)
{
parent::initialize($config);
$this->setTable('products');
}
public static function defaultConnectionName()
{
return 'cloud-firestore';
}
}
//src/Model/Entity/Product.php
namespace App\Model\Entity;
use Cake\ORM\Entity;
/**
* Product Entity
*
* @uses Entity
* @package Entity
*/
class Product extends Entity
{
protected $_accessible = [
'*' => true,
'id' => false,
];
protected $_virtual = [
];
}
## Controllers