acobster/t-hub-service

此包已被弃用且不再维护。未建议替代包。

与Atandra T-HUB的二级服务集成

dev-master 2019-01-04 18:52 UTC

This package is auto-updated.

Last update: 2023-02-15 10:01:10 UTC


README

Atandra

Build Status

概述

这是一个类似于HTTP服务应用,用于将数据库驱动的在线商店与T-HUB桌面应用程序集成。包含的index.php文件可以作为独立的面向Web的脚本使用。

当前实现与特定的数据库结构相关联。也许在未来它将变得更加可配置。也许吧。

注意:此服务仅实现了集成的前两个级别:getOrdersupdateOrdersShippingStatus,如T-HUB服务规范所述。

设置

克隆仓库

$ git clone git@github.com:acobster/t-hub-service.git path/to/public/service/dir

通过在公共服务目录中添加名为thub_config.php的文件来配置服务(它应该在index.php相同的目录中)

<?php

define( 'DB_NAME', 'your_db' );
define( 'DB_USER', 'user' );
define( 'DB_PASSWORD', 'password' );
define( 'DB_HOST', 'localhost' );
define( 'DB_SOCKET', '/tmp/mysql.sock' ); // optional

// Using default values is discouraged in most cases.
// See docblock for THubService::config()
THub\THubService::config(array(
	'viewDir'		=> '/some/dir/',
	'user'			=> 'thub-user',
	'passwordFile'	=> '/path/to/thub.passwd',
	'securityKey'	=> 'some-long-string',
	'requireKey'	=> false // defaults to true
));

?>

要生成密码文件,运行

php -r "echo password_hash('<your desired password>', PASSWORD_DEFAULT);" > /path/to/thub.passwd

请注意,/path/to/thub.passwd文件必须与配置中声明的passwordFile路径匹配。

测试它!

代码附带了一个针对服务端点的各种操作的Postman集合。将test/integration/THUB.postman_collection.json导入Postman开始使用,并尝试其中一个请求。 小心!更新订单配送状态有副作用!

开发

要开始开发,您必须已安装Lando。在克隆后,只需在仓库根目录下运行

lando start

运行测试

存在单元和集成测试,所有测试都在Lando环境中运行

lando unit # runs unit tests
lando e2e  # runs integration tests
lando test # runs entire test suite

Lando Postman环境

代码附带了一个用于上述集合测试的Postman环境。从test/integration/lando.postman_environment.json导入。