PHPackages                             ebilet/common - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. ebilet/common

ActiveLibrary

ebilet/common
=============

E-Bilet Common Package - Merkezi loglama ve ortak işlevler için

1.2.3(9mo ago)08MITPHPPHP ^8.2

Since Aug 5Pushed 9mo agoCompare

[ Source](https://github.com/e-bilet/ebilet-common)[ Packagist](https://packagist.org/packages/ebilet/common)[ RSS](/packages/ebilet-common/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (4)Used By (0)

E-Bilet Common Package
======================

[](#e-bilet-common-package)

E-Bilet mikroservisleri için merkezi loglama ve ortak işlevler paketi. Laravel 12+ ile uyumlu, config-based architecture ve endpoint-specific logging özellikleri ile.

🚀 Özellikler
------------

[](#-özellikler)

- **🔧 Config-Based Architecture**: Tüm ayarlar config dosyasından yönetilir
- **🎯 Endpoint-Specific Logging**: Belirli endpoint'lerde HTTP loglama
- **📊 Merkezi Loglama Sistemi**: RabbitMQ üzerinden log-messages kanalına log gönderimi
- **🌐 HTTP Request/Response Logging**: Otomatik HTTP istek/yanıt loglama
- **⚡ Performance Monitoring**: Performans metrikleri izleme
- **📈 Business Event Logging**: İş olayları loglama
- **🔒 Error Handling**: Gelişmiş hata yönetimi
- **🎨 SOLID Principles**: Clean code ve yüksek OOP standartları

📦 Kurulum
---------

[](#-kurulum)

### 1. Composer ile Paketi Ekleyin

[](#1-composer-ile-paketi-ekleyin)

```
composer require ebilet/common
```

### 2. Service Provider'ı Kaydedin

[](#2-service-providerı-kaydedin)

`bootstrap/providers.php` dosyasında (Laravel 12):

```
return [
    // ...
    Ebilet\Common\ServiceProviders\LoggingServiceProvider::class,
];
```

### 3. Configuration Dosyasını Yayınlayın

[](#3-configuration-dosyasını-yayınlayın)

```
php artisan vendor:publish --provider="Ebilet\Common\ServiceProviders\LoggingServiceProvider"
```

### 4. Environment Variables'ları Ayarlayın

[](#4-environment-variablesları-ayarlayın)

`.env` dosyasında:

```
# RabbitMQ Configuration
RABBITMQ_HOST=localhost
RABBITMQ_PORT=5672
RABBITMQ_USER=guest
RABBITMQ_PASSWORD=guest
RABBITMQ_VHOST=/

# HTTP Logging Configuration
EBILET_HTTP_LOGGING_ENABLED=true
EBILET_HTTP_LOGGING_ENDPOINTS=*
EBILET_HTTP_LOGGING_EXCLUDED_PATHS=/health,/metrics

# Queue Configuration
EBILET_QUEUE_LOG_CHANNEL=log-messages
EBILET_QUEUE_METRICS_CHANNEL=metrics
EBILET_QUEUE_EVENTS_CHANNEL=events

# Performance Monitoring
EBILET_PERFORMANCE_MONITORING_ENABLED=true
```

🎯 Kullanım
----------

[](#-kullanım)

### 1. Basit Loglama

[](#1-basit-loglama)

```
use Ebilet\Common\Facades\Log;

// Temel loglama
Log::info('Kullanıcı giriş yaptı', ['user_id' => 123]);
Log::error('Veritabanı bağlantı hatası', ['error' => $exception->getMessage()]);
Log::warning('Yavaş sorgu tespit edildi', ['query' => $sql, 'duration' => 2.5]);

// HTTP loglama
Log::logHttpRequest('POST', '/api/users', $headers, $body);
Log::logHttpResponse(200, $responseHeaders, $responseBody, 0.15);

// Performans metrikleri
Log::logPerformance('database_query', 0.05, ['table' => 'users']);

// İş olayları
Log::logBusinessEvent('user_registered', [
    'user_id' => 123,
    'email' => 'user@example.com'
]);
```

### 2. Endpoint-Specific Middleware Kullanımı

[](#2-endpoint-specific-middleware-kullanımı)

`bootstrap/app.php` dosyasında (Laravel 12):

```
->withMiddleware(function (Middleware $middleware) {
    $middleware->web(append: [
        \Ebilet\Common\Middleware\HttpLoggingMiddleware::class,
    ]);

    $middleware->api(append: [
        \Ebilet\Common\Middleware\HttpLoggingMiddleware::class,
    ]);
})
```

### 3. Config-Based Endpoint Control

[](#3-config-based-endpoint-control)

`.env` dosyasında:

```
# Tüm endpoint'lerde loglama
EBILET_HTTP_LOGGING_ENDPOINTS=*

# Sadece belirli endpoint'lerde loglama
EBILET_HTTP_LOGGING_ENDPOINTS=GET:/api/users,POST:/api/auth,PUT:/api/profile

# Wildcard kullanımı
EBILET_HTTP_LOGGING_ENDPOINTS=GET:/api/*,POST:/api/*
```

### 4. Queue Manager Kullanımı

[](#4-queue-manager-kullanımı)

```
use Ebilet\Common\Facades\Queue;

// Queue bağlantısı
Queue::connect();

// Log gönderimi
Queue::sendLog([
    'message' => 'Test log',
    'level' => 'info',
    'context' => ['test' => true]
], LogMessageType::APPLICATION_INFO);

// Metric gönderimi
Queue::sendMetric([
    'metric' => 'response_time',
    'value' => 0.15,
    'unit' => 'seconds'
]);

// Event gönderimi
Queue::sendEvent([
    'event' => 'user_registered',
    'data' => ['user_id' => 123]
]);
```

### 5. Enum Kullanımı

[](#5-enum-kullanımı)

```
use Ebilet\Common\Enums\LogMessageType;

// Log mesaj tipi belirleme
$messageType = LogMessageType::HTTP_REQUEST;
$logLevel = $messageType->getLogLevel(); // 'info'
$isCritical = $messageType->isCritical(); // false
$isPerformance = $messageType->isPerformance(); // false
```

⚙️ Konfigürasyon
----------------

[](#️-konfigürasyon)

### Config Dosyası: `config/ebilet-common.php`

[](#config-dosyası-configebilet-commonphp)

```
return [
    /*
    |--------------------------------------------------------------------------
    | RabbitMQ Configuration
    |--------------------------------------------------------------------------
    */
    'rabbitmq' => [
        'host' => env('RABBITMQ_HOST', 'localhost'),
        'port' => env('RABBITMQ_PORT', 5672),
        'user' => env('RABBITMQ_USER', 'guest'),
        'password' => env('RABBITMQ_PASSWORD', 'guest'),
        'vhost' => env('RABBITMQ_VHOST', '/'),
    ],

    /*
    |--------------------------------------------------------------------------
    | Queue Configuration
    |--------------------------------------------------------------------------
    */
    'queues' => [
        'channels' => [
            'log_messages' => env('EBILET_QUEUE_LOG_CHANNEL', 'log-messages'),
            'metrics' => env('EBILET_QUEUE_METRICS_CHANNEL', 'metrics'),
            'events' => env('EBILET_QUEUE_EVENTS_CHANNEL', 'events'),
        ],
        'settings' => [
            'log_messages' => [
                'durable' => env('EBILET_QUEUE_LOG_DURABLE', true),
                'ttl' => env('EBILET_QUEUE_LOG_TTL', 86400000), // 24 hours
                'max_length' => env('EBILET_QUEUE_LOG_MAX_LENGTH', 10000),
            ],
            'metrics' => [
                'durable' => env('EBILET_QUEUE_METRICS_DURABLE', true),
                'ttl' => env('EBILET_QUEUE_METRICS_TTL', 604800000), // 7 days
                'max_length' => env('EBILET_QUEUE_METRICS_MAX_LENGTH', 50000),
            ],
            'events' => [
                'durable' => env('EBILET_QUEUE_EVENTS_DURABLE', true),
                'ttl' => env('EBILET_QUEUE_EVENTS_TTL', 2592000000), // 30 days
                'max_length' => env('EBILET_QUEUE_EVENTS_MAX_LENGTH', 100000),
            ],
        ],
        'delivery_mode' => env('EBILET_QUEUE_DELIVERY_MODE', 2), // Persistent
    ],

    /*
    |--------------------------------------------------------------------------
    | HTTP Logging Configuration
    |--------------------------------------------------------------------------
    */
    'http_logging' => [
        'enabled' => env('EBILET_HTTP_LOGGING_ENABLED', true),
        'endpoints' => env('EBILET_HTTP_LOGGING_ENDPOINTS', '*'),
        'excluded_paths' => env('EBILET_HTTP_LOGGING_EXCLUDED_PATHS', [
            '/health', '/metrics', '/favicon.ico', '/robots.txt', '/.well-known'
        ]),
        'excluded_methods' => env('EBILET_HTTP_LOGGING_EXCLUDED_METHODS', ['OPTIONS']),
        'sensitive_headers' => env('EBILET_HTTP_LOGGING_SENSITIVE_HEADERS', [
            'authorization', 'cookie', 'x-api-key', 'x-auth-token'
        ]),
        'log_request_body' => env('EBILET_HTTP_LOGGING_REQUEST_BODY', true),
        'log_response_body' => env('EBILET_HTTP_LOGGING_RESPONSE_BODY', false),
        'max_body_size' => env('EBILET_HTTP_LOGGING_MAX_BODY_SIZE', 1024 * 1024),
        'slow_request_threshold' => env('EBILET_HTTP_LOGGING_SLOW_THRESHOLD', 2000),
    ],
];
```

📊 Log Message Types
-------------------

[](#-log-message-types)

Paket aşağıdaki log mesaj tiplerini destekler:

### HTTP Logs

[](#http-logs)

- `HTTP_REQUEST`: HTTP istekleri
- `HTTP_RESPONSE`: HTTP yanıtları
- `HTTP_ERROR`: HTTP hataları

### Application Logs

[](#application-logs)

- `APPLICATION_INFO`: Genel bilgi logları
- `APPLICATION_ERROR`: Uygulama hataları
- `APPLICATION_WARNING`: Uyarılar
- `APPLICATION_DEBUG`: Debug logları

### Performance Logs

[](#performance-logs)

- `PERFORMANCE_METRIC`: Performans metrikleri
- `SLOW_REQUEST`: Yavaş istekler
- `MEMORY_USAGE`: Bellek kullanımı

### Business Event Logs

[](#business-event-logs)

- `BUSINESS_EVENT`: İş olayları
- `USER_ACTION`: Kullanıcı aksiyonları
- `SYSTEM_EVENT`: Sistem olayları

### Security Logs

[](#security-logs)

- `SECURITY_ALERT`: Güvenlik uyarıları
- `AUTHENTICATION`: Kimlik doğrulama
- `AUTHORIZATION`: Yetkilendirme

### Database Logs

[](#database-logs)

- `DATABASE_QUERY`: Veritabanı sorguları
- `DATABASE_ERROR`: Veritabanı hataları
- `DATABASE_SLOW_QUERY`: Yavaş sorgular

### External Service Logs

[](#external-service-logs)

- `EXTERNAL_API_CALL`: Dış API çağrıları
- `EXTERNAL_API_ERROR`: Dış API hataları
- `EXTERNAL_SERVICE_TIMEOUT`: Dış servis timeout'ları

🔧 Error Handling
----------------

[](#-error-handling)

```
use Ebilet\Common\Exceptions\LoggingException;

try {
    Log::info('Test message');
} catch (LoggingException $e) {
    // Logging hatası yönetimi
    error_log("Logging error: " . $e->getMessage());
}
```

🧪 Test
------

[](#-test)

```
# Unit testleri çalıştırma
./vendor/bin/phpunit packages/ebilet/common/tests/
```

📋 Gereksinimler
---------------

[](#-gereksinimler)

- **PHP**: ^8.2
- **Laravel**: ^12.0
- **RabbitMQ**: 3.8+
- **php-amqplib**: ^3.0
- **monolog**: ^3.0

🤝 Katkıda Bulunma
-----------------

[](#-katkıda-bulunma)

1. Fork yapın
2. Feature branch oluşturun (`git checkout -b feature/amazing-feature`)
3. Commit yapın (`git commit -m 'Add amazing feature'`)
4. Push yapın (`git push origin feature/amazing-feature`)
5. Pull Request oluşturun

📄 Lisans
--------

[](#-lisans)

Bu paket MIT lisansı altında lisanslanmıştır.

🔄 Versiyon Geçmişi
------------------

[](#-versiyon-geçmişi)

### v1.2.3 (Current)

[](#v123-current)

- **ServiceClient Class Name Fix**: `BaseServiceClient.php` → `ServiceClient.php` dosya adı düzeltmesi
- **Autoload Issues**: Composer autoload sorunları çözüldü
- **Class Not Found Error**: ServiceClient sınıfı bulunamama hatası düzeltildi

### v1.2.2

[](#v122)

- **Service Communication System**: Tamamen yeni servisler arası iletişim sistemi
- **SOLID Architecture**: Interface, Factory, Manager pattern'leri ile temiz mimari
- **User &amp; Order Facades**: Basit facade kullanımı (`User::get()`, `Order::post()`)
- **Configuration Driven**: Config'den service URL'leri okuma
- **Error Handling**: Kapsamlı error handling ve logging
- **Health Check**: Service sağlık kontrolü
- **Method Chaining**: `withToken()`, `withHeaders()`, `timeout()` chaining

### v1.2.1

[](#v121)

- ConfigManager ve Config Facade
- Geliştirilmiş config yapısı
- Kapsamlı dokümantasyon
- Güvenlik ayarları

### v1.2.0

[](#v120)

- Centralized Logger
- Queue Manager
- HTTP Logging Middleware

### v1.1.0

[](#v110)

- Laravel 12 uyumluluğu
- Config-based architecture
- Endpoint-specific logging
- Improved requirements

### v1.0.0

[](#v100)

- İlk stable sürüm
- Temel loglama özellikleri
- RabbitMQ entegrasyonu

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance57

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

286d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8cd929fb29f122eb0a5304609e20f635a906d24d2530f3d589d87a441ebdf5be?d=identicon)[bugrabozkurtt](/maintainers/bugrabozkurtt)

---

Top Contributors

[![bugrabozkurtt](https://avatars.githubusercontent.com/u/23212140?v=4)](https://github.com/bugrabozkurtt "bugrabozkurtt (20 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ebilet-common/health.svg)

```
[![Health](https://phpackages.com/badges/ebilet-common/health.svg)](https://phpackages.com/packages/ebilet-common)
```

###  Alternatives

[magento/community-edition

Magento 2 (Open Source)

12.1k52.1k10](/packages/magento-community-edition)[laravel/nightwatch

The official Laravel Nightwatch package.

3526.1M13](/packages/laravel-nightwatch)[wheelpros/fitment-platform-api

Magento 2 (Open Source)

12.1k1.2k](/packages/wheelpros-fitment-platform-api)[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11120.2M21](/packages/anourvalar-eloquent-serialize)[convenia/pigeon

3233.0k](/packages/convenia-pigeon)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
