jsefton/laravel-mailing-list 问题修复 & 功能扩展

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

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

jsefton/laravel-mailing-list

Composer 安装命令:

composer require jsefton/laravel-mailing-list

包简介

Laravel mailing list manager

README 文档

README

This package gives you a quick out the box mailing list storage and API to use to add people to specific mailing lists

You can create a mailing list and then attach a email contact to a list.

Installation

composer require jsefton/laravel-mailing-list

You will need to publish the config to set if API is enabled

php artisan vendor:publish --tag=mailing-list.config

Next run migrations to add the required tables

php artisan migrate

Usage

Config

The configuration file allows you to enable or disable the API feature. The API feature provides a POST endpoint that you can consume in your application for a sign up form to send the data and have it store against a specific mailing list.

The API flag is set through an environment variable of MAILING_LIST_API

/**
 * Enable API for mailing lists to allow creation
 */
'api' => env('MAILING_LIST_API', true),

You can also change the route that is used for the API subscribe endpoint to anything you desire.

/**
 * Route for API requests (only registered if api is enabled)
 */
'route' => '/api/mailing-list'

The above will result in API POST requests to be sent to /api/mailing-list/{id}, where {id} is the ID of the mailing list.

This is registered within the application with a named route and can be linked to with:

route('api.mailing-list.subscribe', ['id' => 1])

API

The API only exposes an endpoint for people to subscribe in order to not expose any data.

You can send the following data to the endpoint:

{
    "email": "info@endor.digital",
    "first_name": "Jamie", (optional)
    "last_name": "Sefton", (optional)
    "source": "Website" (optional)
}

Many forms will not have 2 different fields for first_name and last_name. So the API has been built to allow you to POST just name field and will automatically split this up into first name and last name. E.g.

{
    "email": "info@endor.digital",
    "name": "Jamie Sefton", (optional)
    "source": "Website" (optional)
}

Console

You can either create a new mailing list directly through the database, with your own UI you create or using the shipped console command. You can do this by running:

php artisan mailing-list:create

This will then ask you to enter a name of the mailing list. Once complete it will return back the ID of the new mailing list for you to use in your application to create POST requests to the API

You can get a list of current mailing lists in your console by running:

php artisan mailing-list:list
+----+------+
| ID | Name |
+----+------+
| 1  | Test |
+----+------+

Models

If you wish to just consume the models within your application and maybe not use the API then you can use the following models. The models are standard eloquent and can be used in a standard Laravel way.

MailingList

namespace: JSefton\MailingList\Models\MailingList

Contains the individual lists that a user is subscribed against, which can be created in the above console command.

You can get the email contacts attached to a specific list once loaded with:

$emails = $mailingList->emails

MailingListEmail

namespace: JSefton\MailingList\Models\MailingListEmail

This is the object of each individual email that is subscribed. They are attached to a MailingList and is unique per email per list.

You can get the mailing list they are attached to with:

$list = $email->mailingList

Please note currently for Laravel 7+ until tested and verified in lower versions.

jsefton/laravel-mailing-list 适用场景与选型建议

jsefton/laravel-mailing-list 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 58 次下载、GitHub Stars 达 1, 最近一次更新时间为 2021 年 05 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-05-03