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

Ip Collection Bundle Laravel Package

tourze/ip-collection-bundle

Tourze IP Collection Bundle packages reusable IP address collection services for Symfony/PHP applications, offering entity mappings and integration hooks so you can store, organize, and query IP lists without rebuilding the same infrastructure.

View on GitHub
Deep Wiki
Context7

Getting Started

  • Install via Composer: composer require tourze/ip-collection-bundle (check that the version constraint matches ^0.1).
  • For Symfony: register Tourze\IpCollectionBundle\IpCollectionBundle in config/bundles.php. For Laravel: look for a service provider or use the underlying IP collection service directly; the bundle name suggests Symfony-first, so expect to wire it manually.
  • Publish/configure any package config (e.g., config/packages/ip_collection.yaml). Start with the default storage (likely in-memory or a simple repository) to verify it works.
  • First use case: capture the client IP from an incoming request and store it for later inspection. Use the provided collector service (inject IpCollectionInterface or similar) in a controller or middleware. Log the IP or persist it to a database table if the bundle provides a Doctrine entity.
  • Where to look first: README.md, src/ for the main service class, and DependencyInjection/ for config options. Since this is 0.1.0, documentation may be minimal—inspect the tests for usage examples.

Implementation Patterns

  • Request-level collection: Add a middleware or event listener that calls the collector on every request. In Symfony, use a kernel event subscriber; in Laravel, a middleware that resolves the collector from the container.
  • Storage strategies: The bundle likely offers multiple backends (array, cache, Doctrine). Configure the one that fits your scale. For high-traffic apps, prefer a fast cache (Redis) over database writes per request.
  • Whitelisting / blacklisting: Use the collected IPs to build allow/deny lists. Combine with Symfony’s IpUtils or Laravel’s Request::ip() for validation.
  • Analytics integration: Dispatch a domain event after collection and listen for it to push IPs to an analytics service or log aggregator. This keeps the bundle decoupled from your business logic.
  • Testing: Mock the collector service in unit tests. For functional tests, use the bundle’s test helpers (if any) to assert that IPs are recorded correctly.

Gotchas and Tips

  • Proxy and load balancer IPs: The bundle may not automatically trust X-Forwarded-For. Configure trusted proxies in your framework first, otherwise you’ll collect the proxy IP instead of the client IP.
  • IPv6 support: Verify that the collector handles IPv6 addresses. If it uses ip2long, IPv6 will break—check for inet_pton or similar.
  • Version 0.1.0 instability: Expect breaking changes in minor releases. Pin the version (0.1.*) and review the changelog before upgrading. The release notes only link to a diff, so read the commit history for details.
  • Symfony vs Laravel: The package is a Symfony bundle; using it in Laravel may require manual service registration. Consider extracting the core IP collection logic if the bundle tightly couples to Symfony components.
  • Performance: Collecting on every request can add overhead. Use sampling or only collect for specific routes. Avoid synchronous database writes in the request cycle—queue them if possible.
  • Extension points: Look for interfaces (e.g., IpStorageInterface) to swap out storage or add custom filtering. The bundle may also expose events you can listen to for custom processing.
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.
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect