定制 unopim/api-php-client 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

unopim/api-php-client

Composer 安装命令:

composer require unopim/api-php-client

包简介

Official PHP API client for the UnoPim PIM — authenticate, paginate, and manage products, categories, attributes, families, channels, locales, and assets. Framework-agnostic, PSR-18 compatible.

README 文档

README

Tests License: MIT

Official PHP client for the UnoPim PIM REST API.

Works in any PHP project — Laravel, Symfony, WordPress, Magento, Drupal, plain PHP.

Install

composer require unopim/api-php-client

That's it. The bundled cURL client works out of the box — no extra HTTP package needed. Want Guzzle or Symfony HttpClient instead? See HTTP clients.

Connect

use Unopim\ApiClient\UnoPimClient;

$client = UnoPimClient::create(
    baseUrl:      'https://your-unopim.example.com',
    clientId:     'your-client-id',
    clientSecret: 'your-client-secret',
    username:     'admin@example.com',
    password:     'your-admin-password',
);

Where do credentials come from? In UnoPim admin: System → API Clients → Create. Note the Client ID & Secret. Username / password = any admin user's login.

Examples

List all products

foreach ($client->products()->iterate() as $product) {
    echo $product['sku'], PHP_EOL;
}

Get one product

$product = $client->products()->get('MY-SKU-001');

Create a product

$client->products()->create([
    'sku'        => 'NEW-SKU',
    'parent'     => null,
    'family'     => 'default',
    'type'       => 'simple',
    'additional' => null,
    'values'     => [
        'common' => [
            'sku'  => 'NEW-SKU',
            'name' => 'My Product',
        ],
        'channel_locale_specific' => [
            'ecommerce' => [
                'en_US' => [
                    'description' => '<p>Hello world.</p>',
                    'price'       => '{"USD":"49.99"}',
                ],
            ],
        ],
    ],
]);

Update a product

$client->products()->update('NEW-SKU', [
    'sku'    => 'NEW-SKU',
    'family' => 'default',
    'type'   => 'simple',
    'values' => [
        'common' => ['sku' => 'NEW-SKU', 'name' => 'Updated Name'],
    ],
]);

Delete a product

$client->products()->delete('NEW-SKU');

Categories, attributes, families…

Same shape — $client->categories(), $client->attributes(), $client->attributeFamilies(), etc.

// All categories
$categories = $client->categories()->list();

// Create attribute
$client->attributes()->create([
    'code'        => 'color',
    'type'        => 'select',
    'labels'      => ['en_US' => 'Color'],
    'is_unique'   => false,
    'is_required' => false,
]);

// Add options to it
$client->attributes()->createOptions('color', [
    ['code' => 'red',  'labels' => ['en_US' => 'Red']],
    ['code' => 'blue', 'labels' => ['en_US' => 'Blue']],
]);

Upload a product image

$client->mediaFiles()->uploadProductMedia('/path/to/image.jpg');

Raw call to any endpoint

If a resource isn't wrapped yet:

$client->get('/api/v1/rest/some-endpoint');
$client->post('/api/v1/rest/some-endpoint', $payload);
$client->put('/api/v1/rest/some-endpoint/code', $payload);
$client->delete('/api/v1/rest/some-endpoint/code');

// Auto-paginates
$all = $client->fetchAll('/api/v1/rest/products', batchSize: 100);

More runnable scripts in examples/.

Available resources

Accessor Methods
$client->locales() list(), get($code)
$client->currencies() list(), get($code)
$client->channels() list(), get($code)
$client->categories() list(), get($code), create($data), update($code, $data)
$client->categoryFields() list(), get($code), create($data), update($code, $data)
$client->attributes() list(), get($code), create($data), update($code, $data), listOptions($code), createOptions($code, $data), updateOptions($code, $data)
$client->attributeGroups() list(), get($code), create($data), update($code, $data)
$client->attributeFamilies() list(), get($code), create($data), update($code, $data)
$client->products() list(), iterate(), get($sku), create($data), update($sku, $data), delete($sku)
$client->configurableProducts() list(), iterate(), get($sku), create($data), update($sku, $data)
$client->mediaFiles() uploadProductMedia($filePath), uploadCategoryMedia($filePath)

Errors

use Unopim\ApiClient\Exception\ApiException;
use Unopim\ApiClient\Exception\AuthenticationException;

try {
    $client->products()->get('MISSING-SKU');
} catch (AuthenticationException $e) {
    // 401 — bad credentials
} catch (ApiException $e) {
    $e->getStatusCode();   // int
    $e->getResponseBody(); // string
    $e->getMessage();
}

Using other HTTP clients

The bundled cURL adapter works for everyone. If you want Guzzle, Symfony HttpClient, or any other PSR-18 client:

Guzzle

composer require guzzlehttp/guzzle guzzlehttp/psr7
use GuzzleHttp\Client as Guzzle;
use GuzzleHttp\Psr7\HttpFactory;
use Unopim\ApiClient\UnoPimClient;

$g = new Guzzle(['timeout' => 30]);
$f = new HttpFactory();

$client = UnoPimClient::createWithHttpClient(
    'https://your-unopim.example.com', 'cid', 'csec', 'admin@example.com', 'pass',
    $g, $f, $f,
);

Symfony HttpClient

composer require symfony/http-client nyholm/psr7
use Symfony\Component\HttpClient\Psr18Client;
use Unopim\ApiClient\UnoPimClient;

$s = new Psr18Client();
$client = UnoPimClient::createWithHttpClient(
    'https://your-unopim.example.com', 'cid', 'csec', 'admin@example.com', 'pass',
    $s, $s, $s,
);

Requirements

  • PHP 8.1+
  • ext-curl, ext-json
  • UnoPim server v2.0+

License

MIT — see LICENSE.

Issues / Contributing

Open an issue or send a PR. See CONTRIBUTING.md.

Maintained by Webkul Software Pvt. Ltd.

unopim/api-php-client 适用场景与选型建议

unopim/api-php-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 25 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 29 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 unopim/api-php-client 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-29