Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Health Check Bundle Laravel Package

ekreative/health-check-bundle

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Lightweight & Focused: The bundle provides a minimal, single-purpose /healthcheck endpoint, aligning well with modern microservices and cloud-native architectures where observability is critical. It avoids bloat while fulfilling a core operational need.
  • Symfony/Laravel Agnostic: Designed for Symfony but leverages Laravel’s compatibility with Symfony bundles (via symfony/flex or manual integration). Works well in Laravel if wrapped in a Laravel-specific facade or service provider.
  • Extensible: Supports custom checks (e.g., Doctrine connections) via configuration, enabling gradual adoption without forcing a monolithic rewrite.

Integration Feasibility

  • Low Barrier to Entry: Requires only Composer installation, bundle registration, and route/security configuration—minimal changes to existing Laravel codebase.
  • Doctrine-Centric: Primarily checks database connectivity, which is valuable but may require additional checks (e.g., Redis, external APIs) for comprehensive health monitoring. Can be supplemented with Laravel’s built-in Database::connection()->getPdo() or third-party packages like spatie/laravel-health.
  • Legacy Compatibility: Works with Laravel 5.5+ (Symfony 3.4+) but may need adjustments for older versions due to dependency constraints (e.g., Symfony components).

Technical Risk

  • Bundle vs. Native Laravel: Laravel lacks a native health-check package, so this introduces a Symfony dependency. Risk mitigated by:
    • Using a Laravel-compatible wrapper (e.g., spatie/laravel-package-tools).
    • Isolating the bundle in a dedicated service container alias.
  • Configuration Overhead: Requires manual route/security setup, which could be error-prone in large teams. Risk reduced by:
    • Providing Laravel-specific installation docs.
    • Using environment variables for critical paths (e.g., HEALTHCHECK_ENABLED).
  • Limited Customization: Hardcoded responses (e.g., HTTP 200/500) may not align with org-specific SLI/SLOs. Mitigate by:
    • Extending the bundle’s HealthCheckController or using middleware to modify responses.

Key Questions

  1. Observability Stack Fit:
    • Does this integrate with existing monitoring tools (e.g., Prometheus, Datadog) via metrics or alerts? If not, will custom middleware be needed?
  2. Performance Impact:
    • What’s the overhead of Doctrine checks in high-traffic environments? Should checks be async or cached?
  3. Security:
    • How will /healthcheck be secured against abuse (e.g., rate-limiting, IP whitelisting) beyond security: false?
  4. Laravel-Specific Gaps:
    • Are there Laravel-native checks (e.g., queue workers, cache, storage) missing that require additional packages?
  5. Upgrade Path:
    • How will future Laravel/Symfony version upgrades affect this bundle? Is there a maintained fork or alternative?

Integration Approach

Stack Fit

  • Laravel Compatibility:

    • Option 1: Direct Bundle Use (Symfony-style):
      • Requires Laravel 5.5+ (Symfony 3.4+ compatibility).
      • Register the bundle in config/app.php under providers and aliases.
      • Override Symfony’s AppKernel with Laravel’s service container (may need custom bootstrapping).
    • Option 2: Laravel Wrapper:
      • Create a Laravel package (e.g., laravel-health-check-bundle) that:
        • Uses illuminate/support instead of Symfony components.
        • Provides a HealthCheckService facade for Laravel’s DI container.
        • Mimics the /healthcheck route via Laravel’s routing system.
      • Preferred for long-term maintainability.
    • Option 3: Hybrid Approach:
      • Use the bundle’s core logic (e.g., Doctrine checks) via Composer but expose it through a Laravel controller/middleware.
  • Dependencies:

    • Doctrine DBAL: Required for database checks. Ensure Laravel’s doctrine/dbal is installed if not already.
    • Symfony Components: HttpFoundation, Routing, DependencyInjection. Laravel already includes these, reducing friction.

Migration Path

  1. Assessment Phase:
    • Audit current health-check mechanisms (e.g., custom /ping endpoints, third-party tools).
    • Define SLIs (e.g., "database response time < 500ms") to validate bundle coverage.
  2. Pilot Deployment:
    • Install the bundle in a staging environment.
    • Test with:
      • Multiple Doctrine connections (if applicable).
      • Edge cases (e.g., failed DB migrations, read-only replicas).
    • Compare response times with existing solutions.
  3. Gradual Rollout:
    • Phase 1: Replace simple /health endpoints with the bundle’s /healthcheck.
    • Phase 2: Add custom checks (e.g., Redis, external APIs) via configuration.
    • Phase 3: Integrate with monitoring tools (e.g., Prometheus client for metrics).

Compatibility

  • Laravel Versions:
    • Tested on Laravel 5.5+ (Symfony 3.4+). For Laravel 10+, check for breaking changes in Symfony dependencies.
    • Use composer require ekreative/health-check-bundle:^1.0 --dev to avoid production conflicts.
  • PHP Versions:
    • Bundle supports PHP 7.2+. Laravel 10+ requires PHP 8.1+, so no conflicts.
  • Doctrine:
    • Works with Laravel’s Doctrine integration (e.g., laravel-doctrine/orm). Verify connection names match (default, mysql, etc.).

Sequencing

  1. Prerequisites:
    • Ensure Doctrine DBAL is installed (composer require doctrine/dbal).
    • Configure config/database.php connections if using non-default names.
  2. Installation:
    • Composer install + bundle registration (or wrapper package).
    • Add route to routes/web.php (or use bundle’s routes.xml via Symfony bridge).
  3. Configuration:
    • Set ekreative_health_check in config/services.php (or config/packages/).
    • Exclude /healthcheck from auth in app/Http/Kernel.php or config/auth.php.
  4. Testing:
    • Validate endpoint returns 200 with healthy payload, 500 on DB failures.
    • Test with curl http://localhost/healthcheck or Postman.
  5. Monitoring:
    • Integrate with APM tools (e.g., New Relic) or custom alerts (e.g., Laravel Horizon).

Operational Impact

Maintenance

  • Bundle Updates:
    • Monitor for Symfony/Laravel version deprecations (e.g., Symfony 4.x EOL).
    • Use composer why-not ekreative/health-check-bundle to check dependency conflicts.
  • Custom Checks:
    • Extend via configuration or override the HealthCheckController. Document customizations for onboarding.
  • Dependency Management:
    • Pin Symfony components to avoid breaking changes (e.g., symfony/http-foundation:^5.4).

Support

  • Troubleshooting:
    • Common issues:
      • Route not found → Verify routes.xml is loaded or Laravel route is added.
      • Auth blocking → Confirm security: false is set for the firewall.
      • Doctrine errors → Check connection names in config/services.php.
    • Enable debug mode (APP_DEBUG=true) for detailed error logs.
  • Community:
    • Low stars/activity (35 stars, 3.4 score) may limit community support. Prioritize internal documentation or fork for critical fixes.

Scaling

  • Performance:
    • Doctrine checks are synchronous. For high-scale apps:
      • Add a cache:remember layer to avoid repeated DB checks.
      • Offload checks to a queue (e.g., Laravel Queues) if health checks are resource-intensive.
    • Benchmark with ab -n 10000 http://localhost/healthcheck to validate latency.
  • Horizontal Scaling:
    • Stateless endpoint; scales naturally with Laravel’s stateless architecture.
    • Consider adding a Cache::forever() header to reduce load balancer health-check frequency.

Failure Modes

Failure Scenario Impact Mitigation
Database connection down 500 response, alerts triggered Configure retries/exponential backoff in checks.
Route misconfiguration 404 instead of health status Use Laravel’s Route::get() fallback.
Auth misconfiguration Endpoint requires login Explicitly exclude in Kernel.php.
Custom check failures False negatives/positives Unit test custom checks.
Symfony dependency conflicts Bundle incompatibility Use a wrapper or vendor patch.

Ramp-Up

  • Onboarding:
    • For Developers:
      • Document the /healthcheck endpoint contract (e.g., JSON schema, rate limits).
      • Provide a HealthCheckTest class to validate responses in PHPUnit.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
daikazu/eloquent-salesforce-objects
unseen-codes/chat
romalytar/yammi-jobs-monitoring-laravel
kisame76/filament-db-table-state
nqxcode/laravel-lucene-search
dpfx/laravel-livewire-wizards
workos/workos-php-laravel
sofa/laravel-global-scope
nawasara/auth-primitives
adhocrat-io/arkhe-main
make-dev/orca-harpoon
itsemon245/lamet
baks-dev/dashboard
amoifr/pickle-panther-bundle
make-dev/orca
dmstr/symfony-system-resources-bundle
dmstr/symfony-job-queue-bundle
dmstr/openapi-json-schema-bundle
dmstr/keycloak-security-bundle
dmstr/doctrine-audit-log-bundle