globalx/laravel-globalx
Composer 安装命令:
composer require globalx/laravel-globalx
包简介
Biblioteca compartilhada Globalx para microserviços Laravel com funcionalidades de gerenciamento de erros, logging, integrações e API Gateway
README 文档
README
Biblioteca compartilhada Globalx para microserviços Laravel com funcionalidades de gerenciamento de erros, logging, integrações e API Gateway.
Instalação
Você pode instalar o pacote via Composer:
composer require globalx/laravel-globalx
O pacote será automaticamente descoberto pelo Laravel. Se você estiver usando uma versão mais antiga do Laravel, registre o service provider no arquivo config/app.php:
'providers' => [ // ... Globalx\LaravelGlobalx\GlobalxServiceProvider::class, ],
Configuração
Publique os arquivos de configuração:
php artisan vendor:publish --tag=globalx-config
Isso criará os arquivos de configuração em config/globalx/:
log.php- Configurações de loggingintegration.php- Configurações de integraçãoapigateway.php- Configurações do API Gateway
Configuração de Ambiente
Adicione as seguintes variáveis ao seu arquivo .env:
# API Gateway API_GATEWAY_URL=https://api-gateway.example.com JOSE_SECRET=your-secret-key # Logging LOG_CHANNEL=stack LOG_DEPRECATIONS_CHANNEL=null LOG_LEVEL=debug
Uso
ErrorManager
Gerenciamento centralizado de erros com códigos únicos por microserviço.
use Globalx\LaravelGlobalx\Facades\ErrorManager; // Obter resposta de erro $errorResponse = ErrorManager::getErrorResponse('10001', 'pt_BR'); // Verificar se erro existe $exists = ErrorManager::errorExists('10001'); // Obter todos os erros $allErrors = ErrorManager::getAllErrors('pt_BR');
LogManager
Sistema de logging com channels específicos por aplicação.
use Globalx\LaravelGlobalx\Facades\LogManager; use Globalx\LaravelGlobalx\LogManager\Enums\LogType; // Escrever log LogManager::write('myapp', LogType::Application, 'info', 'User logged in', ['user_id' => 123]); // Métodos de conveniência LogManager::info('myapp', 'User logged in', ['user_id' => 123]); LogManager::warning('myapp', 'Deprecated feature used'); LogManager::error('myapp', 'Database connection failed'); LogManager::debug('myapp', 'Debug information', ['data' => $data]);
Integration
Biblioteca para consumo de integrações externas com suporte a base64.
use Globalx\LaravelGlobalx\Facades\Integration; // GET request $response = Integration::get('https://api.example.com/data'); // POST request $response = Integration::post('https://api.example.com/data', ['key' => 'value']); // PUT request $response = Integration::put('https://api.example.com/data/1', ['key' => 'value']); // DELETE request $response = Integration::delete('https://api.example.com/data/1');
ApiGateway
Comunicação com API Gateway incluindo headers JOSE automáticos.
use Globalx\LaravelGlobalx\Facades\ApiGateway; // GET request $response = ApiGateway::get('users', ['page' => 1]); // POST request $response = ApiGateway::post('users', ['name' => 'John Doe']); // PUT request $response = ApiGateway::put('users/1', ['name' => 'Jane Doe']); // DELETE request $response = ApiGateway::delete('users/1');
Playgrounds
O pacote inclui endpoints de playground para testar as funcionalidades:
GET /api/v1/globalx/- Informações do pacoteGET /api/v1/globalx/health- Health checkGET /api/v1/globalx/error-manager/- ErrorManager playgroundGET /api/v1/globalx/log/- LogManager playgroundGET /api/v1/globalx/integration/- Integration playgroundGET /api/v1/globalx/apigateway/- ApiGateway playground
Estrutura do Pacote
src/
├── ErrorManager/ # Gerenciamento de erros
│ ├── DTOs/
│ ├── Enums/
│ ├── Services/
│ └── ErrorManager.php
├── LogManager/ # Sistema de logging
│ ├── Enums/
│ ├── Services/
│ └── LogManager.php
├── Integration/ # Integrações externas
│ ├── DTOs/
│ ├── Enums/
│ ├── Services/
│ └── Integration.php
├── ApiGateway/ # Comunicação com API Gateway
│ ├── DTOs/
│ ├── Enums/
│ ├── Services/
│ └── ApiGateway.php
├── Facades/ # Facades do Laravel
├── config/ # Arquivos de configuração
├── lang/ # Arquivos de localização
└── routes/ # Rotas do pacote
Testes
composer test
Contribuição
Por favor, veja CONTRIBUTING.md para detalhes.
Licença
O MIT License (MIT). Por favor, veja License File para mais informações.
Changelog
Por favor, veja CHANGELOG.md para mais informações sobre o que mudou recentemente.
Suporte
Se você descobrir algum problema de segurança, por favor envie um e-mail para security@globalx.com ao invés de usar o issue tracker.
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-10-23