承接 tadasei/backend-trashable-notifications 相关项目开发

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

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

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 Notifiable trait.
  • 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:

  1. Form Request Configuration: Modify the generated form request (App\Http\Requests\SendNotificationRequest) to suit your application's validation rules and logic.

  2. 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.

  3. Notifiable Trait Replacement: The package provides a custom Notifiable trait, which will be published along with the other management utilities. You must replace the built-in Laravel Notifiable trait with this one in your desired notifiable models. For example:

    use App\Traits\Notifiable;

    This ensures that your models properly handle trashable notifications.

  4. Routes Registration: The routes/resources/notification.php file is generated as part of the management utilities. You must register this file in your application's built-in routes/web.php or routes/api.php to make the package routes available. For example, in routes/api.php:

    <?php
    
    require __DIR__ . '/resources/notification.php';

    The generated routes are protected by the auth:sanctum middleware 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
    });
  5. 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.

  1. Copy the Configuration Files:
    Move the generated .conf files to the /etc/supervisor/conf.d directory in your production server. This allows supervisord to pick up the configuration and manage your processes as defined in the files.

  2. 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:

  1. Transform the Configuration File Name:
    Remove the <app_name_in_lower_snake>_ prefix and replace the .conf extension with .log, adding an asterisk (*) at the end. For example:

    • If the configuration file is my_app_worker.conf, the corresponding log file would be worker*.log.
  2. Update Your .gitignore:
    Add the transformed file name to your .gitignore file. For the above example, your .gitignore entry 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 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-05