承接 laraveljutsu/bazooka 相关项目开发

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

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

laraveljutsu/bazooka

Composer 安装命令:

composer require laraveljutsu/bazooka

包简介

Bazooka is a Laravel package that allows developers to simulate controlled failures (like API timeouts) inside their application for resilience testing.

README 文档

README

Logo Laravel Bazooka

Total Downloads Latest Stable Version License

Introduction

Inject chaos into your Laravel application with ease!

Laravel Bazooka is a powerful Laravel package that allows you to inject controlled chaos into your application. Whether you're testing resilience, simulating failures, or just having fun, Bazooka provides a simple and configurable way to disrupt your application's behavior.

Features

  • Inject Chaos Points: Add Bazooka::chaos() calls to your controller methods with a configurable probability.
  • Disruption Strategies: Choose from built-in strategies like latency delays or exception throwing.
  • Command-Line Tools:
    • Inject chaos points into controllers.
    • List all chaos points in your application.
    • Remove chaos points from your codebase.
  • Dry Run Mode: Safely test the removal of chaos points without modifying files.
  • Configurable Probability: Control the likelihood of chaos being injected or triggered.

Installation

You can install the package via Composer:

composer require laraveljutsu/bazooka

Laravel will automatically register the service provider.

If needed, add to config/app.php providers array:

'providers' => [
    // ...
    LaravelJutsu\Bazooka\BazookaServiceProvider::class,
],

Configuration

After publishing the configuration file, you can customize the behavior of Bazooka by editing config/bazooka.php:

To publish the configuration file, run the following command:

php artisan vendor:publish --provider="LaravelJutsu\Bazooka\BazookaServiceProvider" --tag="config"
return [
    'enabled' => env('BAZOOKA_ENABLED', true), // Enable or disable Bazooka globally
    'probability' => 0.2, // Probability of chaos being injected or triggered (0 to 1)
    'strategies' => [
        'latency' => [
            'min_delay' => 100, // Minimum delay in milliseconds
            'max_delay' => 500, // Maximum delay in milliseconds
        ],
        'exception' => [
            'exceptions' => [
                \RuntimeException::class => 'Something went wrong!', // Exception class and message
            ],
        ],
    ],
];

Usage

Inject Chaos Points

Inject chaos points into your controller methods:

php artisan bazooka:inject

You can target specific controllers:

php artisan bazooka:inject --controller=TestController

List Chaos Points

List all chaos points in your application:

php artisan bazooka:list

Example output:

+-----------------------------------+------+--------+
| File                              | Line | Method |
+-----------------------------------+------+--------+
| Http/Controllers/TestController.php | 10   | index  |
+-----------------------------------+------+--------+

Remove Chaos Points

Remove all chaos points from your codebase:

php artisan bazooka:remove

Use the --dry-run option to preview changes without modifying files:

php artisan bazooka:remove --dry-run

Disruption Strategies

Bazooka comes with built-in disruption strategies. You can configure them in config/bazooka.php.

Latency Disruption

Add a delay to your application.

Exception Disruption

Throw a prepared exception.

Example

Controller Before Injection

namespace App\Http\Controllers;

class TestController
{
    public function index()
    {
        return 'Hello World';
    }
}

Controller After Injection

namespace App\Http\Controllers;

class TestController
{
    public function index()
    {
        \LaravelJutsu\Bazooka\Facades\Bazooka::chaos(); // Chaos point injected here
        return 'Hello World';
    }
}

Testing

Run the test suite to ensure everything works as expected:

composer test

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

License

This package is open-source software licensed under the MIT License.

Credits

  • Developed by ludo 🐆
  • Inspired by the need for chaos engineering in Laravel applications.

Enjoy injecting chaos into your Laravel applications with Laravel Bazooka! 🎉

laraveljutsu/bazooka 适用场景与选型建议

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-02-17