r4nkt/laravel-saasparilla 问题修复 & 功能扩展

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

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

r4nkt/laravel-saasparilla

Composer 安装命令:

composer require r4nkt/laravel-saasparilla

包简介

An opinionated collection of functionality to make Laravel SaaS creators' lives a little bit easier.

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

An opinionated collection of functionality to make Laravel SaaS creators' lives a little bit easier.

This package was developed to scratch an itch, but it was also inspired by Freek and his blog post about removing inactive users and teams.

It should also be noted that it was build on another r4nkt package, which you may also want to use for any of your projects.

Finally, it's important to point out that this package benefitted from Spatie's Laravel package skeleton package.

Installation

You can install the package via composer:

composer require r4nkt/laravel-saasparilla

You can publish and run the migrations with:

php artisan vendor:publish --provider="R4nkt\Saasparilla\SaasparillaServiceProvider" --tag="laravel-saasparilla-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --provider="R4nkt\Saasparilla\SaasparillaServiceProvider" --tag="laravel-saasparilla-config"

This is the contents of the published config file:

<?php

use App\Models\User;
use Illuminate\Auth\Events\Verified;
use R4nkt\Saasparilla\Actions\Default\CulledUnverifiedUserNotifier;
use R4nkt\Saasparilla\Actions\Default\DeleteUser;
use R4nkt\Saasparilla\Actions\Default\FindUnverifiedUsers;
use R4nkt\Saasparilla\Actions\Default\FindUsersReadyForDeletion;
use R4nkt\Saasparilla\Actions\Default\MarkUserForDeletion;
use R4nkt\Saasparilla\Actions\Default\UnmarkUserMarkedForDeletion;
use R4nkt\Saasparilla\Features;
use R4nkt\Saasparilla\Mail\CulledUnverifiedUserMail;

return [

    /**
     * Features (not yet complete):
     *  - cleans up unverified users (default/jetstream)
     *     - marking/notifying/unmarking
     *     - deleting
     *  - inactive users, aka unsubscribed/no-longer-on-trial users (default???/jetstream???)
     *     - marking/notifying/unmarking
     *     - deleting
     *  - inactive teams, aka unsubscribed/no-longer-on-trial teams (default???/jetstream???)
     *     - marking/notifying/unmarking
     *     - deleting
     *  - welcoming verified users
     */
    'features' => [

        /**
         * Cleans up unverified users:
         *  - finds users, marks them for deletion, and notifies them
         *  - unmarks users who verify email before grace period expires
         *  - deletes if still not verified after grace period expires
         */
        Features::cleansUpUnverifiedUsers([
            'tidier' => 'unverified-users',
            'unmark_on' => Verified::class,
        ]),

    ],

    'tidiers' => [
        /**
         * Culls unverified users and purges them after grace period expires.
         */
        'unverified-users' => [
            'culler' => 'unverified-users',
            'unmarker' => 'user-for-deletion',
            'handler' => 'purge-culled-users',
        ],
    ],

    'cullers' => [
        /**
         * Finds unverified users, marks them, and notifies them. Unmarks them
         * if/when they verify their email.
         */
        'unverified-users' => [
            'params' => [
                'finder' => 'unverified-users',
                'marker' => 'user-for-deletion',
                'notifier' => 'culled-unverified-user',
            ],
        ],
    ],

    'handlers' => [
        /**
         * Finds culled users and deletes them.
         */
        'purge-culled-users' => [
            'params' => [
                'finder' => 'users-ready-for-deletion',
                'task' => 'delete-user',
            ],
        ],
    ],

    'finders' => [
        /**
         * Finds users that have not verified their email.
         */
        'unverified-users' => [
            'class' => FindUnverifiedUsers::class,
            'params' => [
                'model' => User::class,
                'threshold' => 14,
            ],
        ],
        /**
         * Finds users that are marked for deletion.
         */
        'users-ready-for-deletion' => [
            'class' => FindUsersReadyForDeletion::class,
            'params' => [
                'model' => User::class,
            ],
        ],
    ],

    'markers' => [
        /**
         * Marks users for deletion, which will take place once the grace
         * period has expired.
         */
        'user-for-deletion' => [
            'class' => MarkUserForDeletion::class,
            'params' => [
                'grace' => 30,
            ],
        ],
    ],

    'notifiers' => [
        /**
         * Notifies unverified users that their accounts will be deleted once
         * the grace period has expired.
         */
        'culled-unverified-user' => [
            'class' => CulledUnverifiedUserNotifier::class,
            'params' => [
                'mailable' => CulledUnverifiedUserMail::class,
                'email_attribute' => 'email',
            ],
        ],
    ],

    'tasks' => [
        /**
         * Deletes the given user.
         */
        'delete-user' => [
            'class' => DeleteUser::class,
        ],
    ],

    'unmarkers' => [
        /**
         * Unmarks a user for deletion, effectively reversing the related
         * marker. Unless it's marked for deletion in some other context, it
         * will no longer be deleted.
         */
        'user-for-deletion' => [
            'class' => UnmarkUserMarkedForDeletion::class,
        ],
    ],

];

Usage

To cull unverified users, execute the following Artisan command:

php artisan saasparilla:cull-unverified-users

To delete users that are ready to be deleted, execute the following Artisan command:

php artisan saasparilla:delete-users-ready-for-deletion

Verified Users

By default, Saasparilla is configured to listen to Laravel's Illuminate\Auth\Events\Verified event. When fired, the user who has been verified will be unmarked. (By default, this will not impact users that were not previously marked for deletion.)

Deleting Jetstream Users with Teams

If your project uses Laravel Jetstream and is configured to use teams, then you will want to change your configuration so that the delete-user task uses the R4nkt\Saasparilla\Actions\Jetstream\DeleteUser class instead.

Testing

composer test

Changelog

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

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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

r4nkt/laravel-saasparilla 适用场景与选型建议

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-04-22