gomdimapps / tools
A wrapper of utility tools (HTTP calls, IP lookup, etc.) for Laravel applications.
Requires
- php: ^8.3
- illuminate/cache: ^12.0|^13.0
- illuminate/contracts: ^12.0|^13.0
- illuminate/http: ^12.0|^13.0
- illuminate/support: ^12.0|^13.0
Requires (Dev)
- orchestra/testbench: ^10.0|^11.0
- pestphp/pest: ^2.0|^3.0
- pestphp/pest-plugin-laravel: ^2.0|^3.0
README
A wrapper of utility tools for Laravel applications, built on top of Laravel's own components (illuminate/http, illuminate/cache, illuminate/support) instead of reinventing them.
Requirements
- PHP 8.3, 8.4 or 8.5
- Laravel 12 or 13 (Laravel 10 and 11 are past their security-support window and are no longer supported; Laravel 13 support is best-effort until
pestphp/pest-plugin-laraveladds support for it)
Installation
composer require gomdimapps/tools
The ToolsServiceProvider is auto-discovered by Laravel. If you want to customize the defaults, publish the config file:
php artisan vendor:publish --tag=tools-config
RequestCall
A fluent wrapper around Laravel's Http facade to centralize HTTP calls.
use GomdimApps\Tools\RequestCall; $call = RequestCall::make('https://api.example.com/users', 'POST') ->asJson() ->withToken($token) ->withData(['name' => 'Jane']) ->execute(); if ($call->isSuccessful()) { $user = $call->json(); } // Full request/response/error snapshot, handy for logging $debugData = $call->captureData();
Available methods include withHeaders(), withUserAgent(), withCookies(), withProxy(), withoutVerifying(), withBasicAuth(), asForm(), acceptJson(), timeout(), withQuery(), buffer() and stream().
Using a proxy
withProxy() accepts a single proxy URL or an array to split proxies per protocol:
use GomdimApps\Tools\RequestCall; // Single proxy for all protocols $call = RequestCall::make('https://api.example.com/users') ->withProxy('http://user:pass@proxy.example.com:8080') ->execute(); // Different proxies per protocol, plus a bypass list ("no") $call = RequestCall::make('https://api.example.com/users') ->withProxy([ 'http' => 'http://proxy.example.com:8080', 'https' => 'http://proxy.example.com:8080', 'no' => ['localhost', '127.0.0.1'], ]) ->withoutVerifying() ->execute();
Ip
Resolves geolocation details for an IP address, with an automatic fallback provider and response caching.
use GomdimApps\Tools\Ip; $details = Ip::getDetails('8.8.8.8'); // ['status' => 'success', 'country' => 'United States', ...]
You can also resolve the details for the current request straight from RequestCall:
use GomdimApps\Tools\RequestCall; $details = RequestCall::getIp();
Pix
Builds a Pix "Copia e Cola" payload (EMV BR Code), including the CRC-16 checksum required by the spec.
use GomdimApps\Tools\Pix; $payload = Pix::make( keyType: 'document', pixKey: '11222333000181', merchantName: 'Empresa Teste Ltda', merchantCity: 'Sao Paulo', ) ->amount(150.00) ->txId('PEDIDO123') ->build();
Supported keyType values: document (CPF/CNPJ, digits are stripped), phone (normalized to +55 E.164), email and random. amount(), txId() and description() are optional — when txId() is omitted, the payload defaults to ***, and when amount() is omitted, the amount field is left out entirely.
Configuration
config/tools.php:
return [ 'http' => [ 'timeout' => env('TOOLS_HTTP_TIMEOUT', 30), ], 'ip' => [ 'cache_ttl' => env('TOOLS_IP_CACHE_TTL', 86400), ], ];
Testing
composer install vendor/bin/pest
If you don't have PHP/Composer installed locally, run the test suite in Docker instead, isolated per PHP version (8.3, 8.4 and 8.5):
make test-8.3
make test-8.4
make test-8.5
# runs all three, one after another
make test-all
Each service builds its own image, installs dependencies and runs vendor/bin/pest inside the container.
License
The MIT License (MIT). Please see the LICENSE file for more information.