PHPackages                             phpresilience/ci-guard - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. phpresilience/ci-guard

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

phpresilience/ci-guard
======================

Detect resilience anti-patterns in your PHP code before they cause production incidents.

00PHPCI passing

Since Oct 20Pushed 6mo agoCompare

[ Source](https://github.com/phpresilience/ci-guard)[ Packagist](https://packagist.org/packages/phpresilience/ci-guard)[ RSS](/packages/phpresilience-ci-guard/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

CI-Guard
========

[](#ci-guard)

[![Quality Gates](https://github.com/phpresilience/ci-guard/workflows/Quality%20Gates/badge.svg)](https://github.com/phpresilience/ci-guard/actions/workflows/quality-gates.yml)[![Tests](https://camo.githubusercontent.com/ccd9daca4f5f67a1810de25bff85cd6678bdbd9012da4f83200623d6471cdd24/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f706870726573696c69656e63652f63692d67756172642f7175616c6974792d67617465732e796d6c3f6c6162656c3d7465737473)](https://github.com/phpresilience/ci-guard/actions)[![codecov](https://camo.githubusercontent.com/05b09817847188b04e0d9e16034b6221cb682a507c4492d2877bfaf0e72b098b/68747470733a2f2f636f6465636f762e696f2f67682f706870726573696c69656e63652f63692d67756172642f6272616e63682f6d61696e2f67726170682f62616467652e737667)](https://codecov.io/gh/phpresilience/ci-guard)[![Latest Version](https://camo.githubusercontent.com/49d75b2e69f69730e9b470b8b2fb1f0242686efb00aefe7700222b68fbe96bdb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706870726573696c69656e63652f63692d6775617264)](https://packagist.org/packages/phpresilience/ci-guard)

> **Prevent production incidents before they happen**
> Static analysis and resilience checks for PHP applications

CI-Guard is a comprehensive static analysis tool designed to identify resilience anti-patterns in your PHP codebase. By catching potential production issues during development and CI/CD, it helps you build more reliable applications and avoid costly incidents.

🎯 Vision
--------

[](#-vision)

Every production incident has a signature - a pattern in the code that makes it predictable. CI-Guard's mission is to detect these patterns **before** code reaches production, transforming reactive incident response into proactive prevention.

Inspired by [Reversed Chaos Engineering (RCE)](https://github.com/reversed-chaos-engineering/FOUNDATION) principles, CI-Guard learns from known failure patterns to protect your applications.

🚀 Why CI-Guard?
---------------

[](#-why-ci-guard)

**The Problem:**
Production incidents are expensive - in terms of revenue, user trust, and engineering time. Many incidents share common root causes:

- HTTP calls without timeouts → hanging requests, worker pool exhaustion
- Missing circuit breakers → cascading failures
- N+1 queries → database overload under load
- Memory leaks → OOM kills and service crashes

**The Solution:**
CI-Guard detects these patterns through static analysis, giving you instant feedback in your development workflow and CI pipeline.

**Think of it as:**

- 🛡️ A safety net for your deployment pipeline
- 📊 A resilience linter for PHP
- 🎓 A learning tool that educates your team on reliability patterns
- 🔍 An automated code reviewer focused on production stability

✨ Current Features
------------------

[](#-current-features)

### 🔌 TimeoutGuard - HTTP Timeout Detection

[](#-timeoutguard---http-timeout-detection)

Detects HTTP calls without proper timeout configuration that can cause:

- Worker pool exhaustion
- Cascading failures
- Application-wide unresponsiveness

**Supported HTTP Clients:**

- ✅ Guzzle HTTP Client
- ✅ Symfony HttpClient
- 🚧 cURL (coming soon)
- 🚧 WordPress HTTP API (coming soon)

**Example:**

```
$ vendor/bin/ci-guard ./src

❌ Found 3 issue(s):

📄 ./src/Service/PaymentService.php
  ⚠️ Line 42: Guzzle HTTP request without timeout configuration (Guzzle post)

    // Add timeout configuration:
    $response = $client->request('POST', $url, [
        'timeout' => 10,         // Total request timeout
        'connect_timeout' => 3,  // Connection timeout
    ]);
```

[📖 Read full documentation on HTTP Timeouts](docs/timeout-guard.md)

🗺️ Roadmap
----------

[](#️-roadmap)

CI-Guard is evolving into a comprehensive resilience analysis platform:

### ✅ Phase 1: TimeoutGuard (Current)

[](#-phase-1-timeoutguard-current)

- Guzzle detection
- Symfony HttpClient detection
- CLI reporter
- cURL detection
- JSON reporter
- Configurable rules

### 🔄 Phase 2: CircuitBreakerGuard (Q2 2025)

[](#-phase-2-circuitbreakerguard-q2-2025)

- Detect missing circuit breaker patterns
- Retry strategy validation
- Fallback behavior checks
- External dependency mapping

### 📊 Phase 3: QueryGuard (Q3 2025)

[](#-phase-3-queryguard-q3-2025)

- N+1 query detection (Doctrine)
- N+1 query detection (Eloquent)
- Slow query patterns
- Missing database indexes

### 🧠 Phase 4: MemoryGuard (Q4 2025)

[](#-phase-4-memoryguard-q4-2025)

- Memory leak patterns
- Resource exhaustion risks
- Large dataset handling

### 🎯 Phase 5: Full Resilience Platform (2026)

[](#-phase-5-full-resilience-platform-2026)

- Custom detector plugins
- Baseline comparisons
- Performance regression detection
- GitHub App integration
- ML-powered pattern recognition

📦 Installation
--------------

[](#-installation)

```
composer require --dev phpresilience/ci-guard
```

🚀 Quick Start
-------------

[](#-quick-start)

### Command Line

[](#command-line)

```
# Analyze your source directory
vendor/bin/ci-guard ./src

# Analyze specific files
vendor/bin/ci-guard ./src/Service/PaymentService.php
```

### CI Integration

[](#ci-integration)

#### GitHub Actions

[](#github-actions)

```
name: Resilience Check

on: [pull_request]

jobs:
  ci-guard:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: '8.3'

      - name: Install dependencies
        run: composer install

      - name: Run CI-Guard
        run: vendor/bin/ci-guard ./src
```

#### GitLab CI

[](#gitlab-ci)

```
ci-guard:
  stage: test
  script:
    - composer install
    - vendor/bin/ci-guard ./src
  only:
    - merge_requests
```

📖 Documentation
---------------

[](#-documentation)

- [HTTP Timeout Detection](docs/timeout-guard.md) - Comprehensive guide on TimeoutGuard
- [Architecture](docs/architecture.md) - How CI-Guard works under the hood
- [Contributing](CONTRIBUTING.md) - How to contribute to the project

🎓 Understanding Resilience Patterns
-----------------------------------

[](#-understanding-resilience-patterns)

### What are timeout configurations?

[](#what-are-timeout-configurations)

Timeouts are critical safeguards that prevent your application from hanging indefinitely when external services are slow or unresponsive.

**Without timeout:**

```
// ❌ Dangerous - can hang for minutes
$response = $client->post('https://payment-api.com/charge', [
    'json' => ['amount' => 100],
]);
```

**What happens:**

1. Payment API is experiencing issues (30s response time)
2. PHP-FPM worker waits indefinitely
3. More requests arrive, more workers get blocked
4. Worker pool exhausts (all 50 workers blocked)
5. New requests start queueing → Application appears down
6. Users see timeouts, revenue is lost

**With timeout:**

```
// ✅ Safe - fails fast after 10 seconds
$response = $client->post('https://payment-api.com/charge', [
    'json' => ['amount' => 100],
    'timeout' => 10,
    'connect_timeout' => 3,
]);
```

**What happens:**

1. Payment API is slow (30s response time)
2. Request times out after 10s (configured)
3. Worker is released immediately
4. Application shows error but stays responsive
5. Circuit breaker can kick in (if implemented)
6. Users see error message, can retry

[Learn more about resilience patterns →](docs/timeout-guard.md)

📊 Real-World Impact
-------------------

[](#-real-world-impact)

```
Before CI-Guard:
├─ Incident: Payment API slowdown
├─ Impact: 15 minutes downtime
├─ Lost Revenue: $50,000
└─ Engineering Time: 4 hours debugging + postmortem

After CI-Guard:
├─ Detection: During code review (PR comment)
├─ Impact: None (caught before production)
├─ Lost Revenue: $0
└─ Engineering Time: 5 minutes to add timeout

```

🤝 Contributing
--------------

[](#-contributing)

We welcome contributions! Whether you want to:

- 🐛 Report bugs
- 💡 Suggest new detectors
- 📝 Improve documentation
- 🔧 Submit code

Please check our [Contributing Guide](CONTRIBUTING.md).

📄 License
---------

[](#-license)

MIT License - see [LICENSE](LICENSE) file for details.

🙏 Acknowledgments
-----------------

[](#-acknowledgments)

**Built with:**

- [nikic/php-parser](https://github.com/nikic/PHP-Parser) - PHP parsing and analysis

**Inspired by:**

- [Reversed Chaos Engineering (RCE)](https://github.com/reversed-chaos-engineering/FOUNDATION) - Systematic incident analysis
- The PHP reliability and SRE communities

📬 Stay Updated
--------------

[](#-stay-updated)

- ⭐ Star this repo to follow development
- 🐦 Follow updates on Twitter [@phpresilience](https://twitter.com/phpresilience) (WIP)
- 💬 Join our [Discord community](https://discord.gg/phpresilience) (WIP)

---

**Made with ❤️ for the PHP community**

*Building more resilient PHP applications, one check at a time.*

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance48

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity15

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/3f7125a1568f9e92a454e5a9681c8bc8f9f602550a939ce2e374ca7e4f703940?d=identicon)[mamoot](/maintainers/mamoot)

---

Top Contributors

[![mamoot64](https://avatars.githubusercontent.com/u/6313848?v=4)](https://github.com/mamoot64 "mamoot64 (10 commits)")

### Embed Badge

![Health badge](/badges/phpresilience-ci-guard/health.svg)

```
[![Health](https://phpackages.com/badges/phpresilience-ci-guard/health.svg)](https://phpackages.com/packages/phpresilience-ci-guard)
```

###  Alternatives

[jaeger/querylist-phantomjs

QueryList Plugin: Use PhantomJS to crawl Javascript dynamically rendered pages.(headless WebKit ) 使用PhantomJS采集JavaScript动态渲染的页面

6124.3k1](/packages/jaeger-querylist-phantomjs)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
