gomdimapps/tools
Composer 安装命令:
composer require gomdimapps/tools
包简介
A wrapper of utility tools (HTTP calls, IP lookup, etc.) for Laravel applications.
README 文档
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 10, 11, 12 or 13
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();
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.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-07-09