Skip to content

suyar/hyperf-umeng

Repository files navigation

UMeng Analytics OpenApi

Latest Stable Version Total Downloads License

Installation

Requirements:

  • php: >=8.1
  • ext-swoole: >=5.0 (SWOOLE_HOOK_NATIVE_CURL)
  • Composer >= 2.0
composer require suyar/hyperf-umeng

Usage

Publish the files of the clickhouse component:

php bin/hyperf.php vendor:publish suyar/hyperf-umeng

Modify your config file 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,
    ],
];

Using the default ApiKey and ApiSecurity by [Inject]:

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();
    }
}

Or use factory:

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();
    }
}

Methods

$umeng->uApp; // U-App
$umeng->appTrack; // AppTrack
$umeng->uMini; // U-MiniProgram

Refer:

Via JetBrains

Contact

License

MIT

Donate 🍵

If you are using this program or like it, you can support me in the following ways:

  • Star、Fork、Watch 🚀
  • WechatPay、AliPay ❤
WechatPay AliPay
Wechat QRcode AliPay QRcode