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.
- 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
composer require thoaud/ongoing-warehouse-php- Download the latest release
- Extract to your project directory
- Include the autoloader:
require_once 'path/to/ongoing-api-php/autoload.php';<?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);<?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";
}<?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";
}This library provides access to all Ongoing WMS API endpoints:
ArticlesApi- Manage articles, inventory, and article dataArticleItemsApi- Work with individual article items
OrdersApi- Create and manage customer ordersReturnOrdersApi- Handle return orders
PurchaseOrdersApi- Manage incoming purchase orders
InventoryAdjustmentsApi- Handle inventory adjustments
WarehousesApi- Warehouse information and management
InvoicesApi- Invoice management
TransporterContractsApi- Transporter contract managementParcelTypesApi- Parcel type information
The API uses HTTP Basic Authentication:
$config->setUsername('your-username');
$config->setPassword('your-password');Set your warehouse-specific API URL:
$config->setHost('https://api.ongoingsystems.se/your-warehouse');Enable debug mode for troubleshooting:
$config->setDebug(true);
$config->setDebugFile('/path/to/debug.log');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);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";
}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);composer test# Run PHPStan static analysis
composer phpstan
# Run PHP CodeSniffer
composer phpcs
# Auto-fix coding standards
composer phpcbf# Generate API documentation
composer docsWe welcome contributions! Please see our Contributing Guide for details.
- Documentation: Ongoing WMS API Documentation
- Email: phpdevsec@proton.me
- Issues: GitHub Issues
This library is licensed under the MIT License. See the LICENSE file for details.
See CHANGELOG.md for a list of changes and version history.
- Ongoing Warehouse for providing the API
- OpenAPI Generator for generating the base client code
- Directhouse for development and maintenance
<?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";
}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.
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";
}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.