psinfoodservice/psinfoodserviceapi 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

psinfoodservice/psinfoodserviceapi

最新稳定版本:v1.1.0

Composer 安装命令:

composer require psinfoodservice/psinfoodserviceapi

包简介

A comprehensive PHP client library for the PS in foodservice Web API

README 文档

README

A comprehensive PHP client library for the PS in foodservice Web API (v7). This package simplifies integration with PS in foodservice services by providing a clean, type-safe interface for all API endpoints.

Installation

composer require psinfoodservice/psinfoodserviceapi

Requirements

  • PHP 8.0 or higher
  • Composer
  • PS in foodservice account with API access

Key Features

  • Full API endpoint coverage (~95%)
  • Async/Concurrent requests - Execute multiple API calls in parallel
  • Response caching - Built-in caching for master/reference data
  • Request/Response logging - Middleware for debugging and monitoring
  • Automatic token refresh - Seamless token management
  • Retry with exponential backoff - Resilient request handling
  • Rate limit handling - Auto-wait on 429 responses
  • Comprehensive error handling with trace IDs

Documentation

For complete API documentation, visit the PS in foodservice API Documentation.

Modules

Module Description
authentication Login, logout, token management, webhooks
webApi Core product data operations
lookups Track product updates (GTIN, PSID, ArticleNumber, etc.)
brands Brand information and management
masters Reference data (allergens, nutrients, countries, etc.)
assortment Assortment list management
assets Asset (image/document) information
relations Producer and brand owner information
files File and image retrieval
impactScore Environmental impact scoring
validation Product data validation
mijnPS MijnPS operations (assortment uploads)
helper Utility methods for data processing

Quick Start

<?php
require_once __DIR__ . '/vendor/autoload.php';

use PSinfoodservice\PSinfoodserviceClient;

$client = new PSinfoodserviceClient('preproduction');

// Login
$client->authentication->login('email@example.com', 'password');

// Get product
$product = $client->webApi->getProductSheet(59);
echo $product->summary->name[0]->value;

// Logout
$client->authentication->logoff();

Examples

Async/Concurrent Requests

$async = $client->async();
$async->get('brands', 'Brand/All');
$async->get('masters', 'Master/All');
$results = $async->execute();

Cached Master Data

$cached = $client->cachedMasters();
$masters = $cached->getAllMasters(); // API call
$masters = $cached->getAllMasters(); // From cache

Brand Management

$brands = $client->brands->getAll();
$newBrands = $client->brands->getAllByDate('-1 week');
$brandId = $client->brands->createOrUpdateBrand(['Name' => 'My Brand']);

MijnPS Uploads

$client->mijnPS->uploadAssortment('guid-here', '/path/to/file.xlsx');

Assets & Relations

$assets = $client->assets->getAssetsFromLogistic(12345);
$producers = $client->relations->getProducers();
$brandOwners = $client->relations->getBrandOwners();

Error Handling

try {
    $client->authentication->login('email', 'pass');
} catch (\PSinfoodservice\Exceptions\PSApiException $e) {
    echo $e->getMessage();
    echo $e->getTraceId(); // For debugging
}

Advanced Configuration

$client = new PSinfoodserviceClient(
    environment: 'production',
    verifySSL: true,
    autoRefreshEnabled: true,
    retryConfig: [
        'enabled' => true,
        'max_retries' => 3,
        'rate_limit_auto_wait' => true,
        'logger' => $psrLogger
    ]
);

Development & Testing

The package includes 310+ PHPUnit tests:

composer test
vendor/bin/phpunit --testdox

Service Interfaces

For testability: AuthenticationServiceInterface, BrandServiceInterface, LookupServiceInterface, CacheInterface

Changelog

See CHANGELOG.md for details.

Support

Contact: it@psinfoodservice.com

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固