suyar / hyperf-umeng
UMeng OpenApi.
v3.1.6
2024-09-22 17:20 UTC
Requires
- php: >=8.1
- guzzlehttp/guzzle: ^7.0
- hyperf/contract: ~3.1.0
- hyperf/support: ~3.1.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- hyperf/testing: ~3.1.0
- phpstan/phpstan: ^1.0
- swoole/ide-helper: ^5.0
README
安装
需求
- php: >=8.1
- ext-swoole: >=5.0 (SWOOLE_HOOK_NATIVE_CURL)
- Composer >= 2.0
composer require suyar/hyperf-umeng
使用
发布 clickhouse 组件的文件
php bin/hyperf.php vendor:publish suyar/hyperf-umeng
修改配置文件 config/autoload/umeng.php
<?php declare(strict_types=1); use function Hyperf\Support\env; return [ 'api_key' => (string) env('UMENG_API_KEY'), 'api_security' => (string) env('UMENG_API_SECURITY'), // Guzzle max curl handles. 'max_handles' => 10, // Guzzle default options. 'options' => [ 'timeout' => 0, ], ];
通过 [Inject]
使用默认的 ApiKey 和 ApiSecurity
namespace App\Controller; use Hyperf\Di\Annotation\Inject; use Suyar\UMeng\Client; class IndexController { #[Inject] protected Client $client; public function index() { return $this->client->uapp->getAppCount(); } }
或者使用工厂模式
namespace App\Controller; use Hyperf\Di\Annotation\Inject; use Suyar\UMeng\Client;use Suyar\UMeng\ClientFactory; class IndexController { #[Inject] protected ClientFactory $clientFactory; public function index() { $client = $this->clientFactory->get('apiKey', 'apiSecret'); return $client->uapp->getAppCount(); } }
方法
$umeng->uApp; // U-App $umeng->appTrack; // AppTrack $umeng->uMini; // U-MiniProgram
参考
通过 JetBrains
联系
许可证
捐赠 🍵
如果你在使用这个程序或者喜欢它,你可以以下方式支持我
- 星标、分支、关注 🚀
- 微信支付、支付宝 ❤