malong / productai
Official PHP SDK for ProductAI.
Installs: 4 825
Dependents: 1
Suggesters: 0
Security: 0
Stars: 8
Watchers: 7
Forks: 5
Open Issues: 0
Requires
- php: >=5.6
Requires (Dev)
- phpmd/phpmd: @stable
- phpunit/php-code-coverage: *
- phpunit/phpunit: *
README
ProductAI® SDKs enable using ProductAI® APIs easily in the programming language of your choice. You can use our PHP SDK to send image queries and maintain your datasets.
Install
composer require malong/productai
Version
There is a breaking change between 1.0.0 and 0.4.0. The major changes:
- A better object model in 1.0.0. Each feature is wrapped into a dedicated class. It avoids a super large class in 0.4.0
Compatiblity
All the new features are going to be added into src/API
and src/Core
folder, which contains 1.0.0 code. All the classes under those folders are using the new namespace ProductAI\API
and ProductAI\Core
. If you want to use new features, please the classes under the namespace ProductAI\API
instead of ProductAI
.
No more change will be added into src/API.php
, src/Base.php
, src/ProductSetApi.php
, src/SearchApi.php
, and src/SearchServiceMananagementApi.php
since now. As a consideration of compatiblity, we will keep those codes. You can use new features without modifying any existing code, after upgrading to 1.0.0.
Testing
Create a file named tests/config.inc.php
and define constants as follows:
<?php // get this key from https://console.productai.cn define('ACCESS_KEY_ID', ''); // get this key from https://console.productai.cn define('SECRET_KEY', ''); // this prefix is attached to any object name and description. // then you can easily recognize those objects generated in test cases ( // usually test will automatically clean it, just in case you need manually clean it) define('TEST_PREFIX', ''); // you must prepare a running image search service before running tests define('IMAGE_SEARCH_SERVICE_ID', ""); // you must prepare a running product search service before running tests define('PRODUCT_SEARCH_SERVICE_ID', "");
Run tests:
composer self-update composer install -n vendor/bin/phpunit --bootstrap=tests/config.inc.php tests/
Usage
Please read ProductAI Developers Documentation
中文说明
ProductAI® SDK 提供了 API 请求封装与签名验证功能,用户可以轻松使用 PHP SDK 完成 API 的调用。
安装
推荐中国大陆用户使用国内镜像。
composer require malong/productai
版本
从0.4.0到1.0.0是一个Breaking Change。主要区别:
- 在1.0.0中,使用更好的对象模型来封装ProductAI API。每一个功能会被单独分离到一个独立的类中。避免0.4.0中的超级大类。
兼容性说明
所有的新功能都将加入src\API
和src/Core
目录。这两个目录包含1.0.0版本的新代码。这两个目录下的类均放在新的名称空间ProductAI\API
和ProductAI\Core
内。如果你希望使用新功能,请引用名称空间ProductAI\API
下的新类。
今后,除了bug fix,将不再对以下文件进行调整:src/API.php
, src/Base.php
, src/ProductSetApi.php
, src/SearchApi.php
, 和src/SearchServiceMananagementApi.php
。但是考虑到兼容性,将一直保留这些代码。这样你可以升级productai到1.0.0,使用新功能,但无需对已有代码做任何修改。
测试
创建文件 tests/config.inc.php
并定义如下常量:
<?php // get this key from https://console.productai.cn define('ACCESS_KEY_ID', ''); // get this key from https://console.productai.cn define('SECRET_KEY', ''); // this prefix is attached to any object name and description. // then you can easily recognize those objects generated in test cases ( // usually test will automatically clean it, just in case you need manually clean it) define('TEST_PREFIX', ''); // you must prepare a running image search service before running tests define('IMAGE_SEARCH_SERVICE_ID', ""); // you must prepare a running product search service before running tests define('PRODUCT_SEARCH_SERVICE_ID', "");
运行测试:
composer self-update composer install -n vendor/bin/phpunit --bootstrap=tests/config.inc.php tests/