PHP code example of suyar / hyperf-umeng

1. Go to this page and download the library: Download suyar/hyperf-umeng library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

suyar / hyperf-umeng example snippets




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,
    ],
];

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
shell
php bin/hyperf.php vendor:publish suyar/hyperf-umeng