Download the PHP package ipregistry/ipregistry-laravel without Composer

On this page you can find all versions of the php package ipregistry/ipregistry-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package ipregistry-laravel

Ipregistry

Ipregistry Laravel Library

Packagist Version CI Lint

This is the official Laravel integration for the Ipregistry IP geolocation and threat data API. It is built on top of the official ipregistry/ipregistry-php client library and makes it feel native to Laravel: auto-discovered configuration, a facade, a request macro, route middleware for country and threat blocking, Laravel cache integration, a first-class testing fake, and an artisan command.

Features

Getting started

You need an Ipregistry API key. Sign up at https://ipregistry.co to get one along with free lookups.

Requirements

Installation

Add your API key to .env:

That's it. The service provider is auto-discovered. Optionally publish the configuration file:

Quick start

Read the visitor's data anywhere you have the request. The lookup runs lazily on first access, is cached, and returns null instead of throwing when the visitor IP is private (localhost) or Ipregistry is unreachable:

Or use the facade for explicit lookups. These throw on failure, like the underlying client:

Dependency injection works too: type-hint Ipregistry\Laravel\Ipregistry, or the raw Ipregistry\IpregistryClient for direct SDK access.

Middleware

Enriching requests

The ipregistry middleware performs the lookup before your handlers run. Middleware parameters select the response fields for the route, keeping responses small and fast:

The middleware is optional: $request->ipregistry() triggers the lookup lazily wherever it is first called. Use the middleware when you want the data fetched up front, a per-route field selection, or fail-closed behavior.

Blocking countries

Respond with 451 Unavailable For Legal Reasons by ISO 3166-1 alpha-2 country code:

The static builders validate the country codes at route-definition time, so a typo fails fast instead of silently never matching.

Blocking proxies, Tor, and threats

Respond with 403 Forbidden to visitors flagged by Ipregistry security data. The is_threat, is_attacker, and is_abuser signals are always blocked; anonymization signals are opt-in:

Accepted signals: proxy, tor, vpn, relay, anonymous. Each maps to the same-named security.is_* field of the Ipregistry response (tor also covers is_tor_exit).

Fail open, fail closed

All middleware fail open by default: when the country or threat status could not be determined (private IP, timeout, API error), the visitor is let through and the failure is reported to your exception handler. An Ipregistry outage never locks users out.

For security-sensitive apps that must not serve traffic without IP intelligence, set IPREGISTRY_FAIL_OPEN=false (or 'fail_open' => false): the ipregistry middleware then responds with 503 when a lookup fails.

Ad-hoc decisions stay plain Laravel, no special API needed:

GDPR and EU detection

isThreat() and isBot() follow the same pattern and also accept an IpInfo or nothing (current request):

Configuration

Everything is configured in config/ipregistry.php, backed by environment variables:

Option Environment variable Default Description
api_key IPREGISTRY_API_KEY None Your Ipregistry API key.
base_url IPREGISTRY_BASE_URL default endpoint API endpoint; eu selects the EU-based endpoint, or set a full URL.
cache.enabled IPREGISTRY_CACHE_ENABLED true Cache successful lookups.
cache.store IPREGISTRY_CACHE_STORE default store Any store from config/cache.php.
cache.ttl IPREGISTRY_CACHE_TTL 600 Cache lifetime in seconds.
development_ip IPREGISTRY_DEVELOPMENT_IP None Fixed public IP used when the client IP is private (localhost).
fail_open IPREGISTRY_FAIL_OPEN true Let requests through when lookups fail.
fields IPREGISTRY_FIELDS full response Default field selection for all lookups, e.g. ip,location,security.
hostname IPREGISTRY_HOSTNAME false Resolve reverse-DNS hostnames.
retries.max IPREGISTRY_RETRIES 1 Automatic retries; kept low so failures never stall page loads.
timeout IPREGISTRY_TIMEOUT 5 Per-request timeout in seconds.

Tip: set IPREGISTRY_FIELDS to fetch only what you use, keeping payloads small and lookups fast. For example, ip,location,security covers geo features, blocking, and GDPR detection.

php artisan about shows the effective configuration at a glance.

Client IP and trusted proxies

The visitor IP comes from $request->ip(), so it honors Laravel's trusted proxy configuration. Behind a load balancer or CDN, configure your trusted proxies (e.g. in bootstrap/app.php), otherwise the extracted IP will be your proxy's, not your visitor's:

Private and reserved addresses are never sent to the API. On localhost that means $request->ipregistry() returns null. Set a development IP to exercise geo features:

Caching

Successful lookups are stored in the configured Laravel cache store with a 10-minute lifetime by default, keyed by IP and lookup options. With Redis or Valkey the cache is shared across workers and deploys. Within a single request the result is additionally memoized on the request object, so middleware, guards, controllers, and views share one lookup.

Laravel Octane

The package is Octane-friendly: the client and service are stateless singletons, and per-visitor data is attached to the request instance, never to shared state.

Testing

Call Ipregistry::fake() in your tests to replace the service with a fake. No HTTP request is ever sent, and lookups are recorded for assertions:

Responses are keyed by IP address ('*' is the fallback, 'origin' answers origin lookups) and use the API's payload shape; the ip key is filled in for you. Values can also be ready-made IpInfo instances, or Throwables to simulate failures. Unlike the real service, the fake looks up private IPs too, so feature tests work without trusted-proxy setup.

Available assertions: assertLookedUp(), assertNotLookedUp(), assertLookedUpTimes(), assertNothingLookedUp(), assertOriginLookedUp(), assertUserAgentsParsed(), plus lookups() for the raw list.

Artisan command

Verify your key and inspect responses from the terminal:

Errors

Explicit lookups (Ipregistry::lookup() and friends) throw the client library's exceptions: ApiException for API-reported failures (with typed errorCode) and ClientException for network errors. Both extend IpregistryException. See the ipregistry-php error documentation.

Request-aware helpers ($request->ipregistry(), Ipregistry::forRequest(), the middleware) never throw: failures are reported to your exception handler, null is returned, and the exception is available as $request->attributes->get('ipregistry.error').

Migrating from ipregistry/ipregistry-php

Keep using the SDK directly for queue jobs and batch pipelines if you like; this package registers a ready-configured Ipregistry\IpregistryClient singleton you can inject. What the package adds on top: configuration, request-aware lookups with per-request memoization, IP extraction honoring trusted proxies, Laravel cache wiring, blocking middleware, and the testing fake.

Other resources

License

Apache License 2.0. See LICENSE.


All versions of ipregistry-laravel with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
illuminate/cache Version ^12.0 || ^13.0
illuminate/console Version ^12.0 || ^13.0
illuminate/contracts Version ^12.0 || ^13.0
illuminate/http Version ^12.0 || ^13.0
illuminate/support Version ^12.0 || ^13.0
ipregistry/ipregistry-php Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ipregistry/ipregistry-laravel contains the following files

Loading the files please wait ...