定制 julesgraus/housekeeper 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

julesgraus/housekeeper

最新稳定版本:1.0.0

Composer 安装命令:

composer require julesgraus/housekeeper

包简介

Tools for cleaning old stuff up

README 文档

README

Cleans up old stuff.

Installation

You can install the package via composer:

composer require julesgraus/housekeeper

Make sure your root composer.json does contain a reference to the repository. Make sure you've set up a cron job on the server if you want to automatically trigger the housekeeper.

Usage

Make sure your housekeepable classes will implement the CanDoHouseKeeping interface from this pacakge:

class MyClass implements \JulesGraus\Housekeeper\Contracts\CanDoHouseKeeping {
    //Your regular methods and properties here.
    
    public static function doHousekeeping(OutputStyle $output) {
        //Put your houskeeping code here.
    }
}

You can use the $output variable to write feedback about the housekeeping to the console. You can register your implementation to the housekeeper in a serviceprovider by passing it to the register method of the housekeeper:

\JulesGraus\Housekeeper\Housekeeper::register([
    MyClass::class
]);

Every day at 02:00, the housekeeper will trigger the doHousekeeping methods af all registered classes by default.

Running the housekeeper at a different time:

If you want to do run at a different time you can do so by using the housekeepers schedule command like so:

\JulesGraus\Housekeeper\Housekeeper::schedule(function(\Illuminate\Console\Scheduling\Event $command) {
    $command->twiceDaily(1, 13); //Run the task daily at 1:00 & 13:00
});

Manually running the housekeeper:

You can run php artisan housekeeper:run in your project root to manually run the housekeeper. This can be handy when testing.

Testing

Run tests by running this command in the root of the package.

composer test

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2023-03-06