PHPackages                             hoodslyhub/order-service-client - 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. [API Development](/categories/api)
4. /
5. hoodslyhub/order-service-client

ActiveLibrary[API Development](/categories/api)

hoodslyhub/order-service-client
===============================

A framework-agnostic PHP client for HoodslyHub Order API

1.0.0(8mo ago)03MITPHPPHP &gt;=7.2

Since Sep 3Pushed 8mo agoCompare

[ Source](https://github.com/HypeMill/hoodslyhub-order-client)[ Packagist](https://packagist.org/packages/hoodslyhub/order-service-client)[ RSS](/packages/hoodslyhub-order-service-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (6)Versions (2)Used By (0)

HoodslyHub Order Service Client
===============================

[](#hoodslyhub-order-service-client)

A comprehensive PHP client library for the HoodslyHub Order Management API with advanced caching capabilities.

Features
--------

[](#features)

- ✅ **Complete Order Management**: Create, read, update, delete operations
- ✅ **BOL Generation**: Generate Bills of Lading for orders
- ✅ **Advanced Caching**: Intelligent response caching with multiple adapters
- ✅ **Smart Cache Invalidation**: Automatic cache clearing when data changes
- ✅ **Performance Optimization**: Up to 90% faster response times
- ✅ **Multiple Cache Backends**: Filesystem, Redis, WordPress, and custom adapters
- ✅ **Authentication Handling**: Automatic token management and refresh
- ✅ **PSR-16 Caching**: Built-in caching support for performance optimization
- ✅ **PSR-3 Logging**: Comprehensive logging with configurable log levels
- ✅ **Error Handling**: Detailed exception handling with HTTP status codes
- ✅ **Framework Integration**: Ready-to-use adapters for popular PHP frameworks
- ✅ **PHP 7.2+ Compatible**: Supports PHP 7.2 through PHP 8.3+
- ✅ **Production Ready**: Battle-tested with enhanced caching system

Installation
------------

[](#installation)

Install via Composer:

```
composer require hoodslyhub/order-service-client
```

Requirements
------------

[](#requirements)

- **PHP 7.2 or higher** (tested on 7.2, 7.3, 7.4, 8.0, 8.1+)
- Guzzle HTTP client (6.5+ or 7.0+)
- PSR-16 compatible cache implementation (optional)
- PSR-3 compatible logger (optional)

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

```
use HoodslyHub\OrderService\Client\OrderClient;
use HoodslyHub\OrderService\Client\Config\ClientConfig;

// Create configuration
$config = new ClientConfig([
    'api_key' => 'your-api-key',
    'base_url' => 'https://api.hoodslyhub.com/',
    'remote_domain' => 'your-domain.com'
]);

// Create client
$client = OrderClient::make($config);

// Create an order
$orderData = [
    'customer_name' => 'John Doe',
    'items' => [
        ['name' => 'Product 1', 'quantity' => 2, 'price' => 29.99]
    ]
];

$result = $client->createOrder($orderData);

if ($result['success']) {
    echo "Order created: " . $result['data']['order_id'];
} else {
    echo "Error: " . $result['error'];
}
```

### Advanced Caching

[](#advanced-caching)

The client includes powerful caching capabilities for optimal performance:

```
use HoodslyHub\OrderService\Client\OrderClient;
use HoodslyHub\OrderService\Client\Config\ClientConfig;
use HoodslyHub\OrderService\Client\Cache\FilesystemCache;

// Setup filesystem cache
$cache = new FilesystemCache('/tmp/hoodslyhub_cache', 'order_client_', 3600);

$config = new ClientConfig([
    'api_key' => 'your-api-key',
    'base_url' => 'https://api.hoodslyhub.com/',
    'remote_domain' => 'your-domain.com',
    'cache' => $cache,
    'cache_config' => [
        'token_ttl' => 3600,           // Token cache: 1 hour
        'order_ttl' => 300,            // Order cache: 5 minutes
        'orders_list_ttl' => 60,       // Orders list: 1 minute
        'enable_response_cache' => true, // Enable response caching
        'cache_get_requests' => true,   // Cache GET requests
    ]
]);

$client = OrderClient::make($config);

// Cache management
$client->warmUpCache();         // Pre-populate cache
$client->clearCache();          // Clear all cache
$stats = $client->getCacheStats(); // Get cache statistics
```

#### Available Cache Adapters

[](#available-cache-adapters)

**Filesystem Cache** (recommended for most applications):

```
use HoodslyHub\OrderService\Client\Cache\FilesystemCache;
$cache = new FilesystemCache('/path/to/cache', 'prefix_', 3600);
```

**Redis Cache** (for high-performance applications):

```
use HoodslyHub\OrderService\Client\Cache\RedisCache;
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$cache = new RedisCache($redis, 'hoodslyhub:', 3600);
```

**WordPress Cache** (for WordPress integration):

```
use HoodslyHub\OrderService\Client\Cache\WordPressCache;
$cache = new WordPressCache('hoodslyhub_');
```

### With Logging

[](#with-logging)

```
use HoodslyHub\OrderService\Client\OrderClient;
use HoodslyHub\OrderService\Client\Config\ClientConfig;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;

// Setup logger
$logger = new Logger('order-client');
$logger->pushHandler(new StreamHandler('path/to/your.log', Logger::INFO));

$config = new ClientConfig([
    'api_key' => 'your-api-key',
    'base_url' => 'https://api.hoodslyhub.com/',
    'logger' => $logger
]);

$client = OrderClient::make($config);
```

API Methods
-----------

[](#api-methods)

### Orders

[](#orders)

- `createOrder(array $orderData): array` - Create a new order
- `updateOrder(array $orderData, string $orderId): array` - Update an existing order
- `getOrder(string $orderId): array` - Get order details
- `getOrders(): array` - Get list of orders
- `deleteOrder(string $orderId): array` - Delete an order

### Authentication

[](#authentication)

- `refreshToken(): bool` - Manually refresh the access token using auth/refresh endpoint
- `hasValidToken(): bool` - Check if the current token is valid

#### Refresh Token Functionality

[](#refresh-token-functionality)

The client now uses an optimized token refresh mechanism:

```
// Automatic token refresh on 401 responses
$orders = $client->getOrders(); // Automatically refreshes token if expired

// Manual token refresh
if ($client->refreshToken()) {
    echo "Token refreshed successfully";
}

// Check token validity
if ($client->hasValidToken()) {
    echo "Token is valid";
}
```

**How it works:**

1. **Automatic Refresh**: When a request receives a 401 response, the client automatically calls the `auth/refresh` endpoint
2. **Optimized Endpoint**: Uses `POST /auth/refresh` with the current token as Bearer authorization
3. **Dynamic TTL**: Respects the `expires_in` field from the API response
4. **Fallback**: If refresh fails, automatically falls back to full authentication
5. **Seamless**: Original request is retried after successful token refresh

**Benefits:**

- ⚡ Faster token renewal (no API key transmission)
- 🔒 Enhanced security (reduced API key exposure)
- 🔄 Automatic retry on authentication failures
- 📊 Better performance with longer token lifetimes

Configuration Options
---------------------

[](#configuration-options)

OptionTypeDefaultDescription`api_key`stringrequiredYour API key`base_url`stringrequiredBase URL of the API`remote_domain`stringrequiredYour domain name`timeout`int30Request timeout in seconds`token_cache_duration`int3600Token cache duration in seconds`cache`CacheInterfacenullPSR-16 cache implementation`logger`LoggerInterfacenullPSR-3 logger implementationError Handling
--------------

[](#error-handling)

All methods return an array with the following structure:

```
[
    'success' => bool,
    'status_code' => int,
    'data' => array|null,
    'error' => string|null
]
```

Framework Integration
---------------------

[](#framework-integration)

### Laravel

[](#laravel)

```
// In a service provider
$this->app->singleton(OrderClient::class, function ($app) {
    $config = new ClientConfig([
        'api_key' => config('services.hoodslyhub.api_key'),
        'base_url' => config('services.hoodslyhub.base_url'),
        'remote_domain' => config('services.hoodslyhub.remote_domain'),
        'cache' => $app->make('cache.store'),
        'logger' => $app->make('log')
    ]);

    return OrderClient::make($config);
});
```

### Symfony

[](#symfony)

```
# services.yaml
services:
    HoodslyHub\OrderService\Client\OrderClient:
        arguments:
            $config: '@HoodslyHub\OrderService\Client\Config\ClientConfig'
            $auth: '@HoodslyHub\OrderService\Client\Auth\AuthenticationManager'

    HoodslyHub\OrderService\Client\Config\ClientConfig:
        arguments:
            $options:
                api_key: '%env(HOODSLYHUB_API_KEY)%'
                base_url: '%env(HOODSLYHUB_BASE_URL)%'
                remote_domain: '%env(HOODSLYHUB_REMOTE_DOMAIN)%'
                cache: '@cache.app'
                logger: '@logger'
```

### WordPress

[](#wordpress)

```
// In your plugin or theme
use HoodslyHub\OrderService\Client\OrderClient;
use HoodslyHub\OrderService\Client\Config\ClientConfig;
use HoodslyHub\OrderService\Client\Cache\WordPressCache;

$config = new ClientConfig([
    'api_key' => get_option('hoodslyhub_api_key'),
    'base_url' => get_option('hoodslyhub_base_url'),
    'remote_domain' => get_site_url(),
    'cache' => new WordPressCache()
]);

$client = OrderClient::make($config);
```

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE) file for details.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance60

Regular maintenance activity

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity30

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

251d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/817e98d4e5469e7f4f212c4cf304659d34db0edf1fe2907e5fc108fc5d0d9c68?d=identicon)[md-nurul-islam](/maintainers/md-nurul-islam)

---

Top Contributors

[![md-nurul-islam](https://avatars.githubusercontent.com/u/5057701?v=4)](https://github.com/md-nurul-islam "md-nurul-islam (1 commits)")

---

Tags

apiclientordershoodslyhub

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/hoodslyhub-order-service-client/health.svg)

```
[![Health](https://phpackages.com/badges/hoodslyhub-order-service-client/health.svg)](https://phpackages.com/packages/hoodslyhub-order-service-client)
```

###  Alternatives

[algolia/algoliasearch-client-php

API powering the features of Algolia.

69333.0M114](/packages/algolia-algoliasearch-client-php)[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.5k311.5k5](/packages/theodo-group-llphant)[resend/resend-php

Resend PHP library.

564.7M21](/packages/resend-resend-php)[mozex/anthropic-laravel

Anthropic PHP for Laravel is a supercharged PHP API client that allows you to interact with the Anthropic API

71226.4k1](/packages/mozex-anthropic-laravel)[tilleuls/amazon-mws-orders

Amazon Marketplace Web Service Orders PHP Client Library

1288.1k1](/packages/tilleuls-amazon-mws-orders)

PHPackages © 2026

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