claudeamadu/firebase 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

claudeamadu/firebase

最新稳定版本:v1.0.2

Composer 安装命令:

composer require claudeamadu/firebase

包简介

Simplified Firebase Classes for your PHP projects Straight forward codes to easily use in your projects without hassle

README 文档

README

Simplified Firebase Classes for your PHP projects Straight forward codes to easily use in your projects without hassle

Installation

composer require claudeamadu/firebase

List Classes

FirebaseAuth
FirebaseUser
FirebaseFirestore
FirestoreDB
Query
FieldFilter
CompositeFilter
UnaryFilter
PathBuilder
FirebaseCloudMessaging
Autoload
require 'vendor/autoload.php';

Firebase Auth

Sign in anonymously
$apiKey = 'AIzaSyxxxxxxxxxxxxxxxxxxxx';
$auth = new FirebaseAuth($apiKey);
$token = null;
if ($auth->signInAnonymously()) {
    $token = $auth->getAccessToken()
}
Sign in with email and password
$apiKey = 'AIzaSyxxxxxxxxxxxxxxxxxxxx';
$auth = new FirebaseAuth($apiKey);
$token = null;
$email = $_REQUEST['email'];
$password = $_REQUEST['password'];
if ($auth->signIn($email, $password)) {
    $token = $auth->getAccessToken()
}
Sign up with email and password
$apiKey = 'AIzaSyxxxxxxxxxxxxxxxxxxxx';
$auth = new FirebaseAuth($apiKey);
$token = null;
$email = $_REQUEST['email'];
$password = $_REQUEST['password'];
if ($auth->signUp($email, $password)) {
    $token = $auth->getAccessToken()
}
Firebase user
$user = $auth->currentUser();

Firestore

Setting up
$Database = '(default)';
$ProjectID = 'xxxxxxxxxxx';
// Create an instance of FirebaseFirestore
$firestore = new FirebaseFirestore($token, $Database, $ProjectID);
$db = $firestore->db;
Getting a document
$documentPath = 'users/xxxxxxx@ttu.edu.gh'; 
$document = $db->getDocument('users', $documentPath);
if ($document !== null) {
    echo $document;
}
Updating a document
$data = [
    "user_name" => "WOW 2",    
    "user_id" => "22195",    
];
$db->updateDocument('users','22195',$data);
Fetch a collection
$collectionPath = 'users'; // Replace with your collection path
$collection = $db->getCollection($collectionPath);
if ($collection !== null) {
    echo $collection;
}
Run a query
$fieldFilter = new FieldFilter();
$compositeFilter = new CompositeFilter();

$fieldFilter->equalTo('user_name', 'WOW 2');

$query = $db->query;
$query->from('users')->where2($fieldFilter);
echo $query->run();

Cloud Messaging

<?php
// Usage:
$credentialsPath = 'serviceAccountCredentials.json';
$topics = 'ios_general';
$title = 'Title of Notification';
$body = 'Body of Notification';
$fcm = new FirebaseCloudMessaging($credentialsPath);

$accessToken = $fcm->getAccessToken();
//echo $accessToken;
$response = $fcm->sendFCMNotificationToTopic($accessToken, $topics, $title, $body);
echo $response;

统计信息

  • 总下载量: 10
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2024-05-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固