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

Laravel Route Statistics Laravel Package

bilfeldt/laravel-route-statistics

Logs Laravel route usage statistics by recording and aggregating requests/responses per route, user, and timeframe (hour/day/month) to minimize database storage. Helps spot heavy users, high-traffic endpoints, and suspicious unauthenticated activity.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Observability Layer: Continues to fit as a lightweight, modular observability tool for Laravel, with route-level analytics remaining the core value proposition. No architectural changes that alter this fit.
  • Modular Design: Unchanged; middleware and request macros remain the primary integration points. PHP 8.5 support does not introduce new dependencies or complexity.
  • Aggregation Efficiency: No modifications to aggregation logic, so time-based aggregation (minute/hour/day/month) remains optimized for minimal storage.
  • Extensibility: Custom context data and user-model flexibility are unaffected. PHP 8.5 support broadens compatibility without adding constraints.

Integration Feasibility

  • Laravel Ecosystem Compatibility:
    • Now officially supports PHP 8.5 (previously up to 8.4). This aligns with Laravel’s latest LTS (11.x) and future-proofs adoption.
    • Backward compatibility maintained for PHP 8.1–8.4, ensuring no forced upgrades.
  • Dependency Stack:
    • No changes to core dependencies (bilfeldt/laravel-request-logger v3+), database requirements, or queue support.
    • CI matrix update reflects PHP 8.5 testing but does not impact runtime behavior.
  • Performance Impact:
    • Unchanged. PHP 8.5 optimizations (e.g., enums, typed properties) may yield minor runtime improvements but do not alter the ~1–5ms overhead.
    • Aggregation and queued logging remain unaffected.

Technical Risk

Risk Area Assessment Mitigation
PHP 8.5 Migration Low risk: No breaking changes. Apps using PHP 8.5 can upgrade seamlessly. Test with php -v and composer require to validate compatibility.
DB Bloat Unchanged. Aggregation and TTL strategies remain the primary mitigations. Continue using route:unused and Model Observers for purging.
Middleware Order Unchanged. Early placement in the stack (e.g., before auth) is still critical. Document middleware order in team runbooks.
Context Data Leakage Unchanged. Custom context validation remains a manual responsibility. Use Laravel’s tap() or middleware validation.
Query Performance Unchanged. Artisan commands may still slow during peak usage. Cache results (Redis) or run during off-peak hours.
Upgrade Path Simplified: PHP 8.5 support reduces future friction for teams adopting newer Laravel versions (e.g., 12+). Prioritize upgrades to Laravel 12+ for full feature parity.

Key Questions for Stakeholders

  1. PHP Version Strategy:
    • Should the team upgrade to PHP 8.5 to leverage this update, or maintain PHP 8.4 for stability?
    • Impact: PHP 8.5 may enable future Laravel optimizations but requires testing.
  2. Laravel 12+ Adoption:
    • Does this release align with plans to upgrade to Laravel 12+ (which officially supports PHP 8.5)?
    • Impact: Coupling PHP and Laravel upgrades may reduce migration effort.
  3. CI/CD Pipeline:
    • Are PHP 8.5 test environments already configured in CI? If not, what’s the effort to add them?
    • Impact: Ensures compatibility before production deployment.
  4. Deprecation Timeline:
    • Will PHP 8.1–8.3 support be dropped in future releases (e.g., v5.x)?
    • Impact: May require proactive PHP version alignment.
  5. Performance Benchmarks:
    • Should the team measure the impact of PHP 8.5 on route logging latency (e.g., via Blackfire)?
    • Impact: Validates assumptions about runtime improvements.

Integration Approach

Stack Fit

  • Laravel Versions: Now fully compatible with Laravel 12+ (PHP 8.5). Target Laravel 11–12 for most teams.
  • PHP Versions: 8.1–8.5 supported (previously 8.1–8.4). Encourages migration to PHP 8.5 for long-term support.
  • Database/Queue: Unchanged. Works with MySQL, PostgreSQL, SQLite, and any Laravel-supported queue.
  • Monitoring Stack: Complementary to Telescope/Sentry or standalone for route analytics.

Migration Path

Phase Action Tools/Commands
PHP 8.5 Validation Test the package in a staging environment with PHP 8.5. Verify no regressions. php -v, composer require bilfeldt/laravel-route-statistics:^4.4.0.
Pilot Deployment Deploy to a non-production Laravel 12+ instance with PHP 8.5. Monitor DB/performance. Same as before: php artisan vendor:publish --tag=migrations, then migrate.
Gradual Rollout Migrate route groups (e.g., api, admin) to PHP 8.5 + v4.4.0. Use feature flags for selective logging. Update Kernel.php or route groups incrementally.
Full Adoption Upgrade all environments to PHP 8.5 + Laravel 12+ (if applicable). Leverage PHP 8.5’s performance benefits. composer update, php artisan optimize.
Optimization Benchmark latency with PHP 8.5 using tools like Blackfire or Laravel Debugbar. Compare pre/post-upgrade metrics.

Compatibility

  • Existing Middleware: No conflicts. PHP 8.5’s typed properties/enums are optional and backward-compatible.
  • Custom Auth: Works with Sanctum/Passport as before. No changes to auth()->user() behavior.
  • API Gateways: Ensure X-Forwarded-For is trusted for IP logging (unchanged).
  • Testing: PHPUnit mocking remains identical:
    $this->middleware(RouteStatisticsMiddleware::class)->handle($request);
    

Sequencing

  1. Pre-requisites:
    • Laravel 10+ (recommended: 11–12).
    • PHP 8.1–8.5 (previously 8.1–8.4).
    • Composer: bilfeldt/laravel-request-logger:^4.4.0.
  2. Order of Operations:
    • Validate PHP 8.5 → Publish migrations → Configure middleware → Test with route:stats.
  3. Post-Deployment:
    • Update CI/CD pipelines to include PHP 8.5 testing.
    • Schedule PHP 8.5 upgrades for other Laravel services (if applicable).

Operational Impact

Maintenance

  • DB Schema: Unchanged. Single route_statistics table with no breaking schema changes.
  • Updates:
    • Minor updates (v4.4.x): Zero-downtime. Composer will auto-resolve dependencies.
    • Major updates (v5.0+): Monitor for PHP 8.1–8.3 deprecation notices.
  • PHP 8.5 Benefits:
    • Performance: Potential latency reductions (e.g., enums, attributes).
    • Security: Latest PHP patches included.

Support

  • Troubleshooting:
    • PHP 8.5-specific issues (e.g., attribute syntax) can be debugged with php -r "echo PHP_VERSION;".
    • Use php artisan route:stats --help for command validation.
  • Documentation: Update runbooks to reflect PHP 8.5 compatibility.

Scaling

  • High Traffic: Queued logging (ROUTE_STATISTICS_QUEUE=true) remains the recommended scaling strategy.
  • Multi-Environment: Shared DB or CLI exports for syncing stats across environments (unchanged).

Failure Modes

Scenario Impact Mitigation
PHP 8.5 Regression Rare, but possible if using experimental features. Roll back to PHP 8.4 via composer require php:^8.4.
Middleware Misplacement Logging unauthenticated routes inconsistently. Audit Kernel.php middleware order. Use Route::middleware(['routestatistics'])->group(...) for precision.
DB Connection Issues Que
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.
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony
spatie/flare-daemon-runtime