tanedaa/laravel-webshare
Composer 安装命令:
composer require tanedaa/laravel-webshare
包简介
A small package that integrates webshare.io proxies into Laravel
README 文档
README
Laravel package for integrating webshare.io proxies into your Laravel application.
It supports:
- Syncing purchased proxies from WebShare into your database
- Using a random valid proxy in outgoing Laravel HTTP requests via
Http::webshare() - Accessing random proxy data/URL for other clients
Requirements
- PHP 8.1+
- Laravel 10+
Installation
composer require tanedaa/laravel-webshare
Publish Assets
Publish both config and migrations:
php artisan vendor:publish --tag=webshare
Or publish separately:
php artisan vendor:publish --tag=webshare-config php artisan vendor:publish --tag=webshare-migrations
Run migrations:
php artisan migrate
Configuration
Set your WebShare API key in .env:
WEBSHARE_API_KEY=your_webshare_api_key WEBSHARE_API_URL=https://proxy.webshare.io/api/v2/ WEBSHARE_PROXY_TABLE=webshare_proxies WEBSHARE_TIMEOUT=10 WEBSHARE_CONNECT_TIMEOUT=5 WEBSHARE_RETRY_TIMES=2 WEBSHARE_RETRY_SLEEP_MILLISECONDS=250
Config file: config/webshare.php
Custom API hosts are rejected by default. If you intentionally point the package at a non-WebShare host, set WEBSHARE_ALLOW_CUSTOM_API_URL=true.
Sync Proxies
Use the built-in command:
php artisan webshare:update-proxies
Optional page size:
php artisan webshare:update-proxies --page-size=200
The command paginates through WebShare API results until all purchased proxies are fetched, then upserts them into the configured proxy table. By default, that table is webshare_proxies.
Scheduling
Laravel 11+ (routes/console.php):
use Illuminate\Support\Facades\Schedule; Schedule::command('webshare:update-proxies --page-size=100')->hourly();
Laravel 10 (app/Console/Kernel.php inside schedule()):
$schedule->command('webshare:update-proxies --page-size=100')->hourly();
Usage
1. Laravel HTTP Client Macro
Use a random valid proxy automatically:
use Illuminate\Support\Facades\Http; $response = Http::webshare()->get('https://api.ipify.org?format=json');
You can still chain regular HTTP options:
$response = Http::timeout(15)->webshare()->get('https://httpbin.org/ip');
2. Facade
use Tanedaa\LaravelWebShare\Facades\WebShare; $proxyUrl = WebShare::getRandomProxyUrl(); $proxyData = WebShare::getRandomProxyData(); $proxyCredentials = WebShare::getRandomProxyCredentials();
getRandomProxyData() returns safe proxy metadata without credentials:
[
'proxy_id' => '...',
'address' => 'host:port',
'ip' => 'host',
'port' => 1234,
'is_valid' => true,
'country_code' => '...',
'city_name' => '...',
'asn_name' => '...',
'asn_number' => '...',
]
getRandomProxyCredentials() is available when a non-Laravel HTTP client needs explicit credentials:
[
'address' => 'host:port',
'ip' => 'host',
'port' => 1234,
'username' => '...',
'password' => '...',
'proxy_url' => 'http://user:pass@host:port',
]
Proxy passwords are stored using Laravel's encrypted Eloquent cast and are hidden when the proxy model is serialized.
3. Dependency Injection
use Tanedaa\LaravelWebShare\Services\WebShare; public function __invoke(WebShare $webShare) { return $webShare->getRandomProxyData(); }
tanedaa/laravel-webshare 适用场景与选型建议
tanedaa/laravel-webshare 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 73 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 05 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 tanedaa/laravel-webshare 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tanedaa/laravel-webshare 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 73
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-08