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