autoaction / hg
1.6.1
2023-08-20 18:31 UTC
Requires
- php: >=7.0
- ext-json: *
- ext-redis: *
- autoaction/utils: ^1.12
- guzzlehttp/guzzle: ^6.3
Requires (Dev)
- phpunit/phpunit: ^6.5
This package is auto-updated.
Last update: 2024-09-20 21:00:39 UTC
README
该项目旨在简化与HG API的集成。
依赖项
- Redis
- PHP 7.0或更高版本
- 成为Auto Avaliar / Auto Action的合作伙伴
如何配置您的HG依赖容器?
<?php
use AutoAction\Hg\HgClient;
use AutoAction\Hg\HgConfig;
use AutoAction\Utils\Cache\RedisCustom;
require 'vendor/autoload.php';
// A ideia é usar estas configurações em um container de dependencia do seu projeto
// - - - - - - - - - - - - - - - - - - - - - - - - - -
// Redis
// - - - - - - - - - - - - - - - - - - - - - - - - - -
$redis = new RedisCustom();
// alguns redis não utiliza senha
if('{SE_REDIS_SENHA}'){
$redis->auth('{REDIS_SENHA}');
}
$redis->connect('{REDIS_HOST}', '{REDIS_PORTA}');
// - - - - - - - - - - - - - - - - - - - - - - - - - -
// Configuração
// - - - - - - - - - - - - - - - - - - - - - - - - - -
$config = new HgConfig('NOME_DO_SEU_PROJETO', $redis);
$config->setCountryId('ID_DO_PAIS');
$config->setHost('HOST_DA_HG');
$config->setPartnerUser('USUARIO_DO_PARCEIRO');
$config->setPartnerPassword('SENHA_DO_PARCEIRO');
// - - - - - - - - - - - - - - - - - - - - - - - - - -
// Client
// - - - - - - - - - - - - - - - - - - - - - - - - - -
$client = new HgClient($config);
// a ideia é que seu container de dependencia retorne o HgClient
如何使用HG包?
// um exemplo de um container de dependencia
$client = $this->di->getHgClient();
// recuperando o token de parceiro
$partnerToken = $client->getPartnerToken();
// fazendo o login de um usuário
$user = $client->getUserData('USUARIO', 'SENHA');
// chamando um endpoint qualquer na HG
$config = $client->post('ENDPOINT', ['PARAMETRO' => 'VALOR'], ['PARAMETRO_HEADER','VALOR_HEADER']);
// exemplo de uso para traduções
use AutoAction\Hg\Translate\HgTranslateConfig;
use AutoAction\Hg\Translate\HgTranslate;
use AutoAction\Hg\Translate\HgLocalStringSample;
$client = $this->di->getHgClient();
$config = new HgTranslateConfig();
$config->setSystemId('ID_DO_SISTEMA');
$config->setInstanceId('ID_DA_INSTANCIA');
$translate = HgTranslate::getInstance($config, $client, new HgLocalStringSample);
$string = $translate->get('ROOT_DA_STRING');
您要为项目做出贡献吗?
太好了,您要为项目做出贡献,以下是运行项目Docker的详细信息。
Docker信息
请将其添加到您的hosts文件中
Normalmente este arquivo fica em: `/etc/hosts`
Para iniciar o container rode o comando:
`docker-compose up -d`
### Acessando a URL do projeto
Adicione no seu navegador ou postman `http://web.local:8199`
### Configurando o Xdebug no PhpStorm
Vá no menu de configuração `File > Settings... > Languagens & Frameworks > PHP > Debug`
Na seção `Xdebug` no campo `Debug port:` coloque a porta `10099`
Também é preciso mapear as pastas do container
Vá no menu de configuração `File > Settings... > Languagens & Frameworks > PHP > Servers`
### Outros comandos Docker
Inicia Docker: `docker-compose up -d`
Encerrar Docker: `docker-compose down`
Levantar o docker com rebuild do container: `docker-compose up -d --build`
Entrar no shell do container: `docker exec -it autoaction-hg-phpfpm /bin/sh`
Verificar os logs de acesso do nginx: `docker logs -tf autoaction-hg-web`