定制 simialbi/yii2-firebasemailer 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

simialbi/yii2-firebasemailer

最新稳定版本:0.1.0

Composer 安装命令:

composer require simialbi/yii2-firebasemailer

包简介

A PHP-client-library for using firebase component to send push notifications.

README 文档

README

A lightweight PHP-client-library for using Firebase push notification services with yii2 framework. Reduces the complexity of network-communication between client and SMS gateway, to help save time and money for focusing on their business logic.

Latest Stable Version Total Downloads License

Installation

The preferred way to install this extension is through composer.

Either run

$ php composer.phar require --prefer-dist simialbi/yii2-firebasemailer

or add

"simialbi/yii2-firebasemailer": "^1.0.0"

to the require section of your composer.json.

Usage

In order to use this component, you will need to:

  1. Setup component your application so that the module is available.

Setup component

return [
    // [...]
    'components' => [
        'firebase' => [
            'class' => 'simialbi\yii2\firebasemailer\Mailer',
            'firebaseCredentials' => [
                'type' => 'service_account',
                'project_id' => 'my_app',
                'private_key_id' => '4d95db2814a6e057611f7883a9a243f6',
                'private_key' => '-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n',
                'client_email' => 'firebase-adminsdk-fbsvc@my_app.iam.gserviceaccount.com',
                'client_id' => '000000000000000000001',
                'auth_uri' =>  'https://accounts.google.com/o/oauth2/auth',
                'token_uri' => 'https://oauth2.googleapis.com/token',
                'auth_provider_x509_cert_url' => 'https://www.googleapis.com/oauth2/v1/certs',
                'client_x509_cert_url' => 'https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-fbsvc%40my_app.iam.gserviceaccount.com',
                'universe_domain' => 'googleapis.com'
            ],
            // 'requestOptions' => [
            //    'timeout' => 20,
            //    'proxy' => 'tcp://proxy.example.com:5100'
            // ]
        ]
    ]
];

Example Usage

To send a message create a new Message instance and set at least the content and recipients.

<?php
/** @var \simialbi\yii2\firebasemailer\Mailer $firebase */
$firebase = Yii::$app->get('firebase', true);
$message = $firebase->createMessage();
$message
    ->setSubject('My subject')
    ->setTextBody('My body\nGreetings')
    ->setData([
        'viewToOpen' => 'my_action',
        'actionId' => 123
    ])
    ->to(['topic' => 'my_topic'])
    ->to(['myFirstT0ken', 'my2ndT0ken']) // alternative ;

if ($message->send()) {
    echo 'success';
} else {
    echo 'failure';
}

License

yii2-firebasmailer is released under MIT license. See bundled LICENSE for details.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-02-12