承接 if1024/laravel-wechat-notification 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

if1024/laravel-wechat-notification

Composer 安装命令:

composer require if1024/laravel-wechat-notification

包简介

Wechat template message for Laravel Notification

README 文档

README

Laravel框架下基于 laravel-wechat 使用微信公众号模板消息作为notification通道的composer包。

Latest Stable Version Latest Unstable Version Total Downloads License

安装

$ composer require if1024/laravel-wechat-notification -vvv

使用

例子

<?php

namespace App\Notifications;

use If1024\LaravelWechatNotification\Messages\OfficialAccountTemplateMessage;
use If1024\LaravelWechatNotification\WechatMessage;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;

class TestNotify extends Notification
{
    use Queueable;

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }
    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via(mixed $notifiable): array
    {
        return ['official_account'];
    }

    public function toOfficialAccount(): OfficialAccountTemplateMessage
    {
        $data = [
            'first'    => 'first',
            'keyword1' => 'keyword1',
            'keyword2' => 'keyword2',
            'keyword3' => 'keyword3',
            'remark'   => 'remark',
        ];

        return WechatMessage::officialAccount()->template('template_id')
                            ->url('https://github.com/')
                            ->data($data);
    }
}

支持的 WechatMessage 方法

  • to(string $openid): 设置模板消息接收人的 openid
  • data(array $data): 设置模板消息数据
  • template(string $templateID): 设置模板消息的模板 ID
  • miniprogram(string $appid, string $pagepath): 设置点击模板消息后跳转的小程序,选填
  • url(string $url): 设置点击模板消息后跳转 url,选填

在模型里使用Notifiable triat 来快捷发送消息:

public function routeNotificationForOfficialAccount($notification)
{
    return $this->openid;//返回当前model内的公众号openid字段
}

然后这样发送模板消息。可参考官方文档:消息通知->发送通知

use App\Notifications\TestNotify;

$user->notify(new TestNotify());

批量发送消息

use Illuminate\Support\Facades\Notification;
use App\Notifications\TestNotify;

$users = \App\Models\User::all();
Notification::send($users, new TestNotify());

说明

  1. 如果 miniprogramurl 同时存在,则优先使用小程序跳转,详情请参考官方文档
  2. data()方法接收一个数组,其 key 为模板消息中的关键字,value 可以为字符串或数组。如果为字符串,则默认颜色为 #173177 ;如果为数组,则第一个参数为显示的数据,第二个参数为字体颜色 可参考颜色设置

感谢

感谢 github 上的各位大哥给的参考!感谢超哥的easywechat

License

MIT

if1024/laravel-wechat-notification 适用场景与选型建议

if1024/laravel-wechat-notification 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 1, 最近一次更新时间为 2023 年 01 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「notification」 「laravel」 「wechat」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 if1024/laravel-wechat-notification 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 if1024/laravel-wechat-notification 我们能提供哪些服务?
定制开发 / 二次开发

基于 if1024/laravel-wechat-notification 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-01-10