Weave 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

Nomoreleaksbundle Laravel Package

andrewcarteruk/nomoreleaksbundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation:

    composer require andrewcarteruk/nomoreleaksbundle
    
  2. Register Bundle (Symfony 2/3): Add to app/AppKernel.php:

    new AndrewCarterUK\NoMoreLeaksBundle\NoMoreLeaksBundle(),
    
  3. Basic Configuration (config/packages/no_more_leaks.yaml or app/config/config.yml):

    no_more_leaks:
        doctrine: ~
        monolog: ~
    

    (Equivalent to enabling both Doctrine and Monolog leak fixes with default settings.)

  4. First Use Case:

    • Deploy to production and monitor memory usage. If leaks persist (e.g., Doctrine entity managers or Monolog handlers growing indefinitely), verify the bundle’s fixes are applied via logs or profiling tools.

Implementation Patterns

Core Workflows

  1. Doctrine Leak Prevention:

    • Target: Unclosed entity manager connections or lingering event listeners.
    • Pattern: Configure specific Doctrine managers (e.g., managers: [default, custom]).
    • Integration:
      no_more_leaks:
          doctrine:
              enabled: true
              managers:
                  - default
                  - my_custom_manager
      
    • When to Use: After heavy ORM operations (e.g., bulk inserts) or long-running commands.
  2. Monolog Leak Prevention:

    • Target: Accumulating log handlers (e.g., stream, syslog) not flushed/closed.
    • Pattern: Whitelist channels to monitor (e.g., channels: [app, security]).
    • Integration:
      no_more_leaks:
          monolog:
              enabled: true
              channels:
                  - app
                  - security
      
    • When to Use: High-traffic applications with frequent logging (e.g., APIs, cron jobs).
  3. Combined Usage:

    • Enable both modules for comprehensive leak protection:
      no_more_leaks:
          doctrine: ~
          monolog: ~
      

Advanced Patterns

  • Conditional Enablement: Use environment variables or parameters to toggle features dynamically:
    no_more_leaks:
        doctrine:
            enabled: "%kernel.debug%"  # Disable in prod
    
  • Custom Event Listeners: Extend the bundle’s EventListener class to handle additional leak scenarios (e.g., custom Doctrine extensions).

Gotchas and Tips

Pitfalls

  1. Symfony Version Mismatch:

    • The bundle supports Symfony 2.7–3.0. Using it with newer versions (e.g., 4.x+) may break due to DI container changes.
    • Fix: Check composer.json constraints or fork the bundle.
  2. Doctrine Manager Misconfiguration:

    • If a manager isn’t listed in managers, its leaks won’t be addressed.
    • Debug Tip: Verify managers via:
      $this->get('doctrine')->getManagerNames();
      
  3. Monolog Channel Oversight:

    • Only whitelisted channels are monitored. Unlisted channels may still leak.
    • Tip: Log all channels during testing to identify missing ones.
  4. False Positives:

    • The bundle may flag normal behavior (e.g., Doctrine proxies) as leaks.
    • Validation: Use Xdebug or Blackfire to confirm actual memory growth.

Debugging

  • Enable Verbose Logging: Add to config/packages/monolog.yaml:
    handlers:
        nomoreleaks:
            type: stream
            path: "%kernel.logs_dir%/nomoreleaks.log"
            level: debug
    
  • Check for Overrides: Ensure no other bundles (e.g., custom Doctrine listeners) interfere with the bundle’s cleanup logic.

Extension Points

  1. Custom Leak Handlers: Implement AndrewCarterUK\NoMoreLeaksBundle\LeakHandlerInterface for new leak types (e.g., Symfony cache leaks).
  2. Event Subscribers: Extend the bundle’s EventSubscriber to hook into lifecycle events (e.g., kernel.terminate).
  3. Configuration Overrides: Use compiler passes to modify the bundle’s services dynamically.

Performance Notes

  • Minimal Overhead: The bundle adds negligible runtime cost (primarily during shutdown).
  • Production-Only: Disable in dev/staging to avoid masking actual issues:
    no_more_leaks:
        enabled: "%kernel.environment% == 'prod'"
    
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.
roundly-consulting/kubernetes-api-for-laravel
roundly-consulting/plausible-for-laravel
gvp/gvp-laravel-template
metasyncsite/laravel-metasync-client
roundly-consulting/onboarding-for-laravel
andydefer/laravel-notification
adachsoft/cli-process-tester
jhaskell13/laraflow
sebastienheyd/boilerplate-media-manager
ccast/tagixo-primix
pretendtrue/laravel-builder
sawmainek/laravel-scout-tntsearch-driver
tomshaw/laravel-calendar-table
dibakar/laravel-ownership
steadrun/laravel-monitor
labyrinthe/connect-laravel
elmogy/layan
drewdan/sentinel-client
dskripchenko/laravel-llm
fatryst/nuonuo