承接 thoaud/ongoing-warehouse-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

thoaud/ongoing-warehouse-php

Composer 安装命令:

composer require thoaud/ongoing-warehouse-php

包简介

PHP client library for the Ongoing Warehouse Management System REST API

README 文档

README

Latest Version on Packagist Total Downloads on Packagist License PHP Version

A PHP client library for the Ongoing Warehouse Management System REST API. This library provides a convenient way to interact with the Ongoing WMS API from PHP applications.

Features

  • Complete API Coverage: All Ongoing WMS REST API endpoints are supported
  • Type Safety: Full PHP type hints and return type declarations
  • PSR Standards: Compliant with PSR-7, PSR-18, and PSR-4
  • Modern PHP: Requires PHP 7.4+ with modern features
  • Composer Ready: Easy installation via Composer
  • Well Documented: Comprehensive PHPDoc comments

Installation

Via Composer

composer require thoaud/ongoing-warehouse-php

Manual Installation

  1. Download the latest release
  2. Extract to your project directory
  3. Include the autoloader:
require_once 'path/to/ongoing-api-php/autoload.php';

Quick Start

Basic Configuration

<?php

require_once 'vendor/autoload.php';

use OngoingAPI\Configuration;
use OngoingAPI\Api\ArticlesApi;

// Configure the API client
$config = new Configuration();
$config->setHost('https://api.ongoingsystems.se/your-warehouse');
$config->setUsername('your-username');
$config->setPassword('your-password');

// Create an API instance
$articlesApi = new ArticlesApi(null, $config);

Example: Get All Articles

<?php

use OngoingAPI\Api\ArticlesApi;
use OngoingAPI\Configuration;

// Setup configuration
$config = new Configuration();
$config->setHost('https://api.ongoingsystems.se/your-warehouse');
$config->setUsername('your-username');
$config->setPassword('your-password');

// Create API client
$articlesApi = new ArticlesApi(null, $config);

try {
    // Get all articles for a goods owner
    $articles = $articlesApi->articlesGetAll(123); // goods_owner_id = 123
    
    foreach ($articles as $article) {
        echo "Article: " . $article->getArticleName() . "\n";
        echo "Stock: " . $article->getInventoryInfo()->getSellableNumberOfItems() . "\n";
    }
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}

Example: Create an Order

<?php

use OngoingAPI\Api\OrdersApi;
use OngoingAPI\Configuration;
use OngoingAPI\Model\GetOrderModel;
use OngoingAPI\Model\GetOrderLine;

// Setup configuration
$config = new Configuration();
$config->setHost('https://api.ongoingsystems.se/your-warehouse');
$config->setUsername('your-username');
$config->setPassword('your-password');

// Create API client
$ordersApi = new OrdersApi(null, $config);

try {
    // Create order model
    $order = new GetOrderModel();
    $order->setOrderNumber('ORD-001');
    $order->setGoodsOwnerId(123);
    
    // Add order line
    $orderLine = new GetOrderLine();
    $orderLine->setRowNumber(1);
    $orderLine->setArticleNumber('ART-001');
    $orderLine->setNumberOfItems(5);
    
    $order->setOrderLines([$orderLine]);
    
    // Create the order
    $result = $ordersApi->ordersPut($order);
    echo "Order created successfully!\n";
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}

API Endpoints

This library provides access to all Ongoing WMS API endpoints:

Articles

  • ArticlesApi - Manage articles, inventory, and article data
  • ArticleItemsApi - Work with individual article items

Orders

  • OrdersApi - Create and manage customer orders
  • ReturnOrdersApi - Handle return orders

Purchase Orders

  • PurchaseOrdersApi - Manage incoming purchase orders

Inventory

  • InventoryAdjustmentsApi - Handle inventory adjustments

Warehouses

  • WarehousesApi - Warehouse information and management

Invoices

  • InvoicesApi - Invoice management

Transport

  • TransporterContractsApi - Transporter contract management
  • ParcelTypesApi - Parcel type information

Configuration Options

Authentication

The API uses HTTP Basic Authentication:

$config->setUsername('your-username');
$config->setPassword('your-password');

Host Configuration

Set your warehouse-specific API URL:

$config->setHost('https://api.ongoingsystems.se/your-warehouse');

Debug Mode

Enable debug mode for troubleshooting:

$config->setDebug(true);
$config->setDebugFile('/path/to/debug.log');

Custom HTTP Client

You can use a custom HTTP client:

use GuzzleHttp\Client;

$client = new Client([
    'timeout' => 30,
    'verify' => false // Only for development
]);

$articlesApi = new ArticlesApi($client, $config);

Error Handling

The library throws exceptions for API errors:

try {
    $articles = $articlesApi->articlesGetAll(123);
} catch (\OngoingAPI\ApiException $e) {
    echo "API Error: " . $e->getMessage() . "\n";
    echo "Response Code: " . $e->getCode() . "\n";
    echo "Response Body: " . $e->getResponseBody() . "\n";
} catch (\Exception $e) {
    echo "General Error: " . $e->getMessage() . "\n";
}

Pagination

Many API endpoints support pagination. Use the max_articles_to_get parameter:

// Get first 100 articles
$articles = $articlesApi->articlesGetAll(123, null, null, 100);

// Get next 100 articles (using article_system_id_from)
$nextArticles = $articlesApi->articlesGetAll(123, null, $lastArticleId, 100);

Development

Running Tests

composer test

Code Quality

# Run PHPStan static analysis
composer phpstan

# Run PHP CodeSniffer
composer phpcs

# Auto-fix coding standards
composer phpcbf

Building Documentation

# Generate API documentation
composer docs

Contributing

We welcome contributions! Please see our Contributing Guide for details.

Support

License

This library is licensed under the MIT License. See the LICENSE file for details.

Changelog

See CHANGELOG.md for a list of changes and version history.

Acknowledgments

Example: Get Article Items (with Pagination)

<?php

use OngoingAPI\Api\ArticleItemsApi;
use OngoingAPI\Configuration;

// Setup configuration
$config = new Configuration();
$config->setHost('https://api.ongoingsystems.se/your-warehouse');
$config->setUsername('your-username');
$config->setPassword('your-password');

// Create API client
$articleItemsApi = new ArticleItemsApi(null, $config);

try {
    // Get article items for a goods owner (with pagination)
    $goodsOwnerId = 123; // Replace with your goods owner ID
    $maxArticlesToGet = 100;
    $articleSystemIdFrom = null;
    $allArticleItems = [];
    do {
        $response = $articleItemsApi->articleItemsGetArticleItemsModel(
            $goodsOwnerId,
            null, // article_number
            $articleSystemIdFrom, // article_system_id_from
            $maxArticlesToGet
        );
        foreach ($response->getArticleItems() as $item) {
            echo "ArticleItemId: " . $item->getArticleItemId() . "\n";
            echo "Batch: " . $item->getBatch() . "\n";
            echo "Serial: " . $item->getSerial() . "\n";
            echo "Status code: " . $item->getStatusCode() . "\n";
            // ... access other fields as needed ...
            $allArticleItems[] = $item;
        }
        // Pagination: set articleSystemIdFrom to the last article system ID
        $articleSystemIdFrom = $response->getArticleSystemId() + 1;
    } while (count($response->getArticleItems()) === $maxArticlesToGet);
    echo "Total article items fetched: " . count($allArticleItems) . "\n";
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}

Migration from Legacy Method

If you're using the legacy articleItemsGetArticleItems() method, you should migrate to the new articleItemsGetArticleItemsModel() method:

// Old way (deprecated)
$articleItems = $api->articleItemsGetArticleItems($goodsOwnerId);
foreach ($articleItems as $articleModel) {
    foreach ($articleModel->getItems() as $item) {
        // Process item
    }
}

// New way (recommended)
$response = $api->articleItemsGetArticleItemsModel($goodsOwnerId);
foreach ($response->getArticleItems() as $item) {
    // Process item directly
}

The new method provides better consistency and easier access to article items.

Error Handling and Debugging

The API client provides comprehensive error handling with detailed exception messages:

try {
    $response = $articleItemsApi->articleItemsGetArticleItemsModel($goodsOwnerId);
    // Process response
} catch (\OngoingAPI\ApiException $e) {
    echo "API Error: " . $e->getMessage() . "\n";
    echo "Status Code: " . $e->getCode() . "\n";
    echo "Response Body: " . $e->getResponseBody() . "\n";
    echo "Response Headers: " . print_r($e->getResponseHeaders(), true) . "\n";
} catch (\InvalidArgumentException $e) {
    echo "Invalid Argument: " . $e->getMessage() . "\n";
} catch (Exception $e) {
    echo "Unexpected Error: " . $e->getMessage() . "\n";
}

Debug Mode

Enable debug mode to log all HTTP requests and responses:

$config->setDebug(true);
$config->setDebugFile('/tmp/ongoing-api-debug.log');

This will help you troubleshoot API issues and understand the exact requests being made.

thoaud/ongoing-warehouse-php 适用场景与选型建议

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

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

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

围绕 thoaud/ongoing-warehouse-php 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-22