定制 highperapp/cli 二次开发

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

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

highperapp/cli

Composer 安装命令:

composer require highperapp/cli

包简介

CLI runtime for cron jobs, queue workers, and custom commands for HighPer Framework

README 文档

README

CLI runtime for cron jobs, queue workers, and custom commands for HighPer Framework.

Features

  • 🚀 CLI Command Interface: Command-line interface for HighPer Framework operations
  • Advanced Task Scheduling: Cron-like job scheduling with overlap prevention
  • 🔄 Memory-Optimized Queue Workers: Multi-process queue processing with automatic restarts
  • 📊 Real-time Monitoring: Comprehensive status reporting and health checks
  • 🎯 Command Auto-Discovery: Automatic command registration and management
  • 🔧 Environment Configuration: Flexible configuration management
  • 🔒 Process Control: Signal handling and graceful shutdowns
  • 📈 Performance Optimization: C10M support with Rust FFI acceleration

Installation

composer require highperapp/cli

Queue Worker Management

# Start single queue worker
bin/highper queue:work redis --queue=default --memory=128M

# Start multiple workers
bin/highper queue:work redis --processes=4 --max-jobs=1000

# Worker with timeout and retry configuration
bin/highper queue:work redis --timeout=3600 --max-tries=3 --delay=60

Task Scheduling

# Run scheduled tasks
bin/highper schedule:run

# Run with overlap prevention
bin/highper schedule:run --no-overlap --verbose

Programming Interface

Application Setup

<?php
use HighPerApp\HighPer\CLI\Application;

$app = new Application('HighPer App', '1.0.0');

// Auto-discover commands
$app->discoverCommands(__DIR__ . '/commands');

// Register workers
$app->registerWorker('email_processor', function($data) {
    // Process email job
    return "Email sent to: {$data['email']}";
}, [
    'memory_limit' => '256M',
    'timeout' => 1800,
    'max_jobs' => 500
]);

Queue Workers

use HighPerApp\HighPer\CLI\Workers\QueueWorker;

$worker = new QueueWorker([
    'adapter' => 'redis',
    'queue' => 'high_priority',
    'memory_limit' => '128M',
    'timeout' => 3600,
    'max_jobs' => 1000,
    'sleep_on_empty' => 5,
    'max_tries' => 3
]);

// Start with status callback
$worker->work(function($status) {
    switch ($status['type']) {
        case 'job_completed':
            echo "Job completed: {$status['job_class']}\n";
            break;
        case 'job_failed':
            echo "Job failed: {$status['error']}\n";
            break;
    }
});

Task Scheduling

use HighPerApp\HighPer\CLI\Schedulers\TaskScheduler;

$scheduler = new TaskScheduler([
    'prevent_overlap' => true,
    'lock_path' => '/tmp/scheduler-locks'
]);

// Schedule command execution
$scheduler->command('backup:database')
          ->daily()
          ->withoutOverlapping()
          ->environments(['production']);

// Schedule callable execution
$scheduler->call(function() {
    // Cleanup temporary files
    return "Cleanup completed";
})->everyFiveMinutes();

// Schedule job class execution
$scheduler->job('App\Jobs\SendNewsletter')
          ->weekly()
          ->timeout(3600)
          ->description('Send weekly newsletter');

// Run due tasks
$results = $scheduler->runDueTasks();

Custom Commands

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class BackupCommand extends Command
{
    protected static $defaultName = 'backup:create';
    
    protected function configure(): void
    {
        $this->setDescription('Create application backup');
    }
    
    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $output->writeln('Creating backup...');
        
        // Backup logic here
        
        $output->writeln('Backup completed successfully!');
        return Command::SUCCESS;
    }
}

Testing

The package includes comprehensive test suites:

# Run all tests
vendor/bin/phpunit

# Run specific test suites
vendor/bin/phpunit --testsuite=Unit
vendor/bin/phpunit --testsuite=Integration
vendor/bin/phpunit --testsuite=Performance
vendor/bin/phpunit --testsuite=Concurrency

# Generate coverage report
vendor/bin/phpunit --coverage-html=coverage/html

Requirements

  • PHP 8.3+ (Required)
  • PHP 8.4 (Supported)
  • Symfony Console ^6.0
  • cron/cron ^3.0
  • Optional extensions:
    • ext-pcntl - Process control for multi-worker support
    • ext-posix - POSIX functions for Unix process management
    • ext-redis - Redis queue adapter support

Environment Configuration

# Application environment
APP_ENV=production

# Queue worker configuration  
QUEUE_CONNECTION=redis
QUEUE_DEFAULT=default

License

MIT

highperapp/cli 适用场景与选型建议

highperapp/cli 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 07 月 12 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 highperapp/cli 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-12