baks-dev/ozon
Laravel/PHP модуль для работы с Ozon API. Установка через Composer (baks-dev/ozon), поддержка PHP 8.4+, версия 7.4.10. В комплекте тесты PHPUnit (группа ozon). Лицензия MIT.
Laravel Native Integration:
OzonServiceProvider to register bindings (e.g., OzonClient, repositories) in Laravel’s IoC container. Override or extend this in config/app.php:
'providers' => [
BaksDev\Ozon\OzonServiceProvider::class,
],
Ozon facade for concise API calls (e.g., Ozon::orders()->fetch()), reducing boilerplate. Customize facade aliases in config/app.php:
'aliases' => [
'Ozon' => BaksDev\Ozon\Facades\Ozon::class,
],
.env system for Ozon credentials (e.g., OZON_CLIENT_ID, OZON_CLIENT_SECRET). Publish the package’s config with:
php artisan vendor:publish --provider="BaksDev\Ozon\OzonServiceProvider" --tag="config"
OzonOrderCreated). Dispatch events in the package’s logic and listen in your app:
// In a service
event(new OzonOrderCreated($order));
// In EventServiceProvider
protected $listen = [
OzonOrderCreated::class => [
HandleOzonOrder::class,
],
];
HttpClient or Guzzle. Ensure consistency by configuring retries and timeouts in config/http.php:
'timeout' => 30,
'connect_timeout' => 10,
'retry' => [
'enabled' => true,
'max_attempts' => 3,
],
Database/ORM:
Order, Product) to Eloquent models for persistence. Example:
class OzonOrder extends Model {
protected $casts = [
'created_at' => 'datetime:Y-m-d H:i:s',
'items' => 'array',
];
}
ozon_orders, ozon_products) to sync data bidirectionally.SyncOzonInventory) to avoid blocking requests:
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
class SyncOzonInventory implements ShouldQueue {
use Queueable, SerializesModels;
public function handle() {
Ozon::products()->syncInventory();
}
}
Testing:
MockHttp to test API interactions without hitting Ozon’s servers:
$this->mock(Http::class, function ($mock) {
$mock->shouldReceive('post')
->once()
->with('https://api.ozon.ru/orders', ['data' => $payload])
->andReturn(Http::response(['success' => true]));
});
php artisan test --group=ozon
Assessment Phase (1–2 weeks):
Setup and Configuration (1 week):
composer require baks-dev/ozon
.env and config/ozon.php.Core Integration (2–3 weeks):
Advanced Features (1–2 weeks):
Testing and Validation (2 weeks):
Deployment and Monitoring (Ongoing):
Log::channel('ozon')) and alerts for failures.laravel/framework package constraints in composer.json:
"require": {
"laravel/framework": "^10.0"
}
composer.json overrides if needed:
"config": {
"platform": {
"php": "8.4.0"
}
}
7.4.x) to align with Ozon’s API versions.Phase 1: Core Sync (Orders + Catalog)
OzonOrderRepository and OzonProductRepository.SyncOzonOrders).Phase 2: Real-Time Updates
OzonWebhookHandler to process events (e.g., order_created).Phase 3: Advanced Features
OzonAnalyticsService).Phase 4: Optimization
Package Updates:
composer.json to avoid unexpected updates:
"require": {
"baks-dev/ozon": "^7.4.0"
}
composer update baks-dev/ozon cautiously.Configuration Drift:
.env or Laravel’s config files. Use environment-specific files (e.g., .env.production) for production.Deprecation Handling:
config or a package like spatie/laravel-feature-flags to toggle deprecated features.Ozon::setLogger(Log::channel('ozon'));
OzonApiException:
try {
Ozon::
How can I help you explore Laravel packages today?