saythanks/laravel-apex 问题修复 & 功能扩展

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

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

saythanks/laravel-apex

Composer 安装命令:

composer require saythanks/laravel-apex

包简介

SMS Portal Notification Channel for Apex in Laravel

README 文档

README

Send SMS notifications in Laravel powered by Apex Messaging. This package provides an easy-to-use notification channel for Laravel that integrates with the Apex Messaging API.

Installation

You can install the package via composer:

composer require saythanks/laravel-apex

The package will automatically register its service provider.

Configuration

You can publish the config file with:

php artisan vendor:publish --tag="laravel-apex-config"

Environment Variables

Add the following variables to your .env file:

# Required Settings
APEX_API_TOKEN=your_api_token_here        # Your Apex API token
APEX_SOURCE_ADDRESS=YOUR_SENDER_ID        # Sender ID/From name

# Optional Settings with defaults
APEX_HOST=https://papi.apex-messaging.com/        # API endpoint (default shown)
APEX_MESSAGE_TYPE=1                               # 1=Promotional, 2=Transactional, 3=OTP (default: 1)
APEX_MESSAGE_ENCODING=0                           # 0=GSM, 1=ASCII, 8=UCS2 (Unicode) (default: 0)
APEX_CALLBACK_URL=https://your-domain.com/webhook # URL for delivery reports
APEX_DELIVERY_ENABLED=true                        # Enable/disable delivery reports
APEX_STORE_CACHE_ENABLED=false                    # Store message details in cache
APEX_STORE_CACHE_TTL=86400                        # Cache TTL in seconds (24 hours)

Usage

Setting up your Notifiable Model

Add a routeNotificationForApex method to your notifiable class:

public function routeNotificationForApex($notification)
{
    return $this->phone_number; // Return the phone number to receive SMS
}

If you don't implement this method, the package will fall back to routeNotificationForSms.

Creating Notifications

<?php

namespace App\Notifications;

use Illuminate\Notifications\Notification;
use LaravelApex\Messages\ApexMessage;
use LaravelApex\Enums\MessageType;

class AccountActivated extends Notification
{
    public function via($notifiable)
    {
        return ['apex']; // Use the Apex channel
    }

    public function toApex($notifiable)
    {
        return (new ApexMessage("This is an example message!"))
            ->messageType(MessageType::TRANSACTIONAL)
            ->userReferenceId('account-'.$notifiable->id);
    }
}

Available Message Methods

  • content($text): Set the message content
  • messageType($type): Set the message type (1=Promotional, 2=Transactional, 3=OTP)
  • messageEncoding($encoding): Set the message encoding (0=GSM, 1=ASCII, etc.)
  • callbackUrl($url): Set a callback URL for delivery reports
  • userReferenceId($id): Set a custom reference ID for tracking

Integration with Website Project

Setup as a Channel Option

To use Apex in your main application:

  1. Publish the config file to your project:

    php artisan vendor:publish --tag="laravel-apex-config"
    
  2. Add the required environment variables to your .env file (see Environment Variables section above).

  3. Configure your notifiable models and create your notifications. ], ],

    
    

Tracking Delivery Reports

The application using this package should implement its own webhook handling for delivery reports. Configure the callback URL in your environment settings:

APEX_CALLBACK_URL=https://your-domain.com/api/webhooks/apex/delivery-report

Implement a controller in your application to process the delivery reports and update your database accordingly.

Data Encoding Values

CodeEncoding
0Default (GSM)
1ASCII
2Octet
3Latin1
4Octet Unspecified
6Cyrillic
7Latin Hebrew
8UCS2

Message Types

CodeType
1Promotional
2Transactional
3OTP

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

License

The MIT License (MIT). Please see License File for more information.

TODO

  • Add HLR when details are available

saythanks/laravel-apex 适用场景与选型建议

saythanks/laravel-apex 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 93 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 09 月 18 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-09-18