tadasei/backend-trashable-notifications
Composer 安装命令:
composer require tadasei/backend-trashable-notifications
包简介
A package that provides stubs for soft deletable database notifications support
README 文档
README
This package provides stubs for managing trashable (soft deletable) database notifications in the backend of a Laravel application. It simplifies common Index, Store, Update, and Delete notification operations by providing pre-defined structures.
Features
- Quickly generate trashable database notifications management files and handling logic.
- Customize and extend generated code to fit your project's needs.
- Improve development efficiency by eliminating repetitive tasks.
Installation
Install the package via Composer by running:
composer require tadasei/backend-trashable-notifications --dev
Usage
Publishing Trashable Notifications Management Utilities
To publish the utilities, including the supervisord configuration files, run:
php artisan trashable-notifications:install
This command generates all necessary files, including:
- Notification-related form requests.
- Policies for managing trashable notifications.
- A custom
Notifiabletrait. - Route files for notification management.
- Database migration files.
- Supervisord configuration files for production queue management.
Configuration
After publishing the utilities, follow these steps to complete the configuration:
-
Form Request Configuration: Modify the generated form request (
App\Http\Requests\SendNotificationRequest) to suit your application's validation rules and logic. -
Policy Configuration: Update the generated policy (
App\Policies\DatabaseNotificationPolicy) to control access to notification management operations, ensuring it aligns with your project's authorization system. -
Notifiable Trait Replacement: The package provides a custom
Notifiabletrait, which will be published along with the other management utilities. You must replace the built-in LaravelNotifiabletrait with this one in your desired notifiable models. For example:use App\Traits\Notifiable;
This ensures that your models properly handle trashable notifications.
-
Routes Registration: The
routes/resources/notification.phpfile is generated as part of the management utilities. You must register this file in your application's built-inroutes/web.phporroutes/api.phpto make the package routes available. For example, inroutes/api.php:<?php require __DIR__ . '/resources/notification.php';
The generated routes are protected by the
auth:sanctummiddleware by default. If your project uses a different authentication guard, you may need to update the middleware to fit your authentication system.Route::middleware('auth:your_guard')->group(function () { // Register routes });
-
Running the Migration: The package generates a migration as part of the utilities. You need to run this migration to set up the necessary database structure for managing trashable notifications. Use the following Artisan command:
php artisan migrate
These steps are necessary to ensure that the package integrates smoothly with your application's existing structure.
Using Supervisord Configuration Files in Production
The supervisord configuration files, generated by the php artisan trashable-notifications:install command, are essential for managing queues in production.
-
Copy the Configuration Files:
Move the generated.conffiles to the/etc/supervisor/conf.ddirectory in your production server. This allowssupervisordto pick up the configuration and manage your processes as defined in the files. -
Learn More About Supervisor:
For further details on how to configure and manage Laravel queues with Supervisor, refer to the Laravel documentation on Supervisor configuration.
Managing Log Files in Production
When using the package in production, log files generated by the supervisord configuration files must be excluded from source control to prevent unnecessary clutter in your versioning system.
Each generated supervisord configuration file has a name format:
<app_name_in_lower_snake>_<file_name>.conf
To exclude the associated log files, perform the following steps:
-
Transform the Configuration File Name:
Remove the<app_name_in_lower_snake>_prefix and replace the.confextension with.log, adding an asterisk (*) at the end. For example:- If the configuration file is
my_app_worker.conf, the corresponding log file would beworker*.log.
- If the configuration file is
-
Update Your
.gitignore:
Add the transformed file name to your.gitignorefile. For the above example, your.gitignoreentry would look like this:worker*.log
This ensures that log files generated in production do not get included in your source control repository.
Further Customization
The generated code serves as a starting point. You can further extend and customize it to fit your project’s needs.
Contributing
Contributions are welcome! If you have suggestions, bug reports, or feature requests, please open an issue on the GitHub repository.
License
This package is open-source software licensed under the MIT license.
tadasei/backend-trashable-notifications 适用场景与选型建议
tadasei/backend-trashable-notifications 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 54 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 09 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「backend」 「notification」 「laravel」 「stubs」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 tadasei/backend-trashable-notifications 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tadasei/backend-trashable-notifications 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 tadasei/backend-trashable-notifications 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This package makes it easy to send notifications via AfricasTalking with Laravel
This bundle offers a simple backend explanation form field (inputType).
Preview of settings in footer of tt_content element in page module.
Apple Push Notification & Feedback Provider
Throttle notifications on a per-channel basis
An interactive tour through the TYPO3 backend.
统计信息
- 总下载量: 54
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-09-05