PHP Luminova: IP Address Info Provider Configuration
Configure IP information lookups, caching, and trusted proxies.
The IP Configuration class allows developers to configure settings related to IP address lookup in their applications. It provides properties to specify the IP address API provider for IP info lookup, the API key, and caching of lookup results.
Class Definition
- Full namespace:
App\Config\IPConfig - File path:
/app/Config/IPConfig.php - This configuration derives from Luminova\Base\AbstractConfig.
- This class is final.
Properties
apiProvider
Specify the IP address API provider to use when looking up user IP address information.Available Providers: ipapi and iphub
ipapi: Provides IP geolocation and network information.iphub: Provides IP intelligence, including VPN, proxy, and hosting detection.
public string $apiProvider = 'iphub';If the value is not one of the supported providers,
IP::info()returns an error result with status700.
ipHubVersion
The API version used by IPHub. This only applies when $apiProvider is set to iphub.
public string $ipHubVersion = 'v2';apiKey
Specify the API key for the configured IP address provider. Obtain the key from the provider's dashboard.
public string $apiKey = '';When empty, requests are sent without authentication. For
ipapithe key is sent as thekeyquery parameter, and foriphubit is sent in theX-Keyrequest header.
cacheIpDetail
Determines whether successful IP lookup results should be cached. When enabled, results are saved to avoid repeated external API requests.
public bool $cacheIpDetail = true;Cached results are stored in
/writeable/caches/ip/asip_info_{ip}.json. UseIP::clearInfoCache()to delete cached details.
cacheExpiration
Defines how long cached IP information remains valid, in seconds.
0: Cache indefinitely (never expires).>0: Cache expires after the specified number of seconds.
public int $cacheExpiration = 604800;The default is 7 days. Negative values are treated as
0.
Trusted Proxies
Configure trusted proxy IP addresses and CIDR subnets in Security configuration.
IP::isTrustedProxy() reads that setting and supports IPv4 and IPv6 addresses, including CIDR notation. If no trusted proxies are configured, it returns true.