定制 globalx/laravel-globalx 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

Latest Version on Packagist Total Downloads Software License

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 logging
  • integration.php - Configurações de integração
  • apigateway.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 pacote
  • GET /api/v1/globalx/health - Health check
  • GET /api/v1/globalx/error-manager/ - ErrorManager playground
  • GET /api/v1/globalx/log/ - LogManager playground
  • GET /api/v1/globalx/integration/ - Integration playground
  • GET /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.

globalx/laravel-globalx 适用场景与选型建议

globalx/laravel-globalx 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 10 月 23 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「logging」 「laravel」 「integration」 「api-gateway」 「microservices」 「error-management」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 globalx/laravel-globalx 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 globalx/laravel-globalx 我们能提供哪些服务?
定制开发 / 二次开发

基于 globalx/laravel-globalx 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 10
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-23