Download the PHP package xyj2156/k3cloud-client without Composer

On this page you can find all versions of the php package xyj2156/k3cloud-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package k3cloud-client

简体中文 | English

Latest Version on Packagist Total Downloads PHP from Packagist Tests

k3cloud-client —— 面向金蝶云(K/3 Cloud)WebAPI 的非官方 PHP 客户端

一个轻量、无第三方依赖、独立编写的 K/3 Cloud WebAPI 客户端。它以"快速上手"为核心, 支持你在真实环境里会遇到的两种认证方式:

非官方。 这是针对公开的 K/3 Cloud HTTP 接口做的 clean-room 独立实现,与任何金蝶 官方 SDK 无隶属、认可或衍生关系,且不含任何官方 SDK 代码。“金蝶 / Kingdee”“K/3 Cloud” 为其权利人所有,这里仅用于描述本客户端所对接的接口。


安装

需要 PHP 8.1+ 与 ext-curl。

快速上手

方式 A —— 第三方应用签名

方式 B —— 用户名 / 密码会话

两种方式的创建完全一致 —— 都是一个"返回客户端"的具名构造器。选项链式写法也与认证方式无关:

链式选项随时可调用:每个都返回同类新客户端,传输层重建以使设置生效,并把当前鉴权"搬迁"过去。 因此在凭据不变的前提下,用户名/密码会话可跨一次重配置存活(不会二次登录)——登录仍然至多一次、 惰性、发生在第一个请求,而且这"一次"如今可以跨进程:kdsessionid 默认会落盘复用(见下节)。 只有更换凭据(或调用 ->relogin())才会触发一次新的认证。

进阶:直接构造 Config

如果你需要在创建客户端之前先组装 / 持久化配置,可显式使用 K3Cloud\Config 再注入 —— 与具名构造器等价:

会话持久化(默认开启)

PHP 的 Web / 脚本请求是"一次进程一次请求"的模型:如果 kdsessionid 只放在内存里, 每个新进程(cron、队列 worker、每一次 HTTP 请求)都要先付一次 ValidateUser 登录往返。 因此密码模式下登录成功后,会话 Cookie 会默认写入磁盘并在后续进程中复用:

⚠️ 安全提示:kdsessionid 等同一个短期有效的登录凭据——拿到它的进程在你的服务端会话 过期之前,可以该用户身份调用 WebAPI。文件以 0600、目录以 0700 写入,但共享主机上 的 sys_get_temp_dir() 未必可靠。多用户环境请指定专属目录,或干脆关闭落盘。

三个开关(仅密码模式有意义,签名模式下为无害空操作):

自定义存储只需实现 K3Cloud\Auth\SessionStore 的三个方法(load / save / forget, 按凭据指纹键控)。多个 Web 节点共享一份存储时,登录成本即摊薄为集群级一次。

上手就这么简单:创建客户端、调用操作。登录与签名都自动完成,会话怎么存、存哪里、要不要存都由你决定。

返回值

每个操作都返回一个 K3Cloud\Result:

方法 含义
->payload() 解码后的响应体(数组 / 标量)
->rows() 查询响应的行列表
->isSuccess() 业务是否成功
->errorMessage() 首条错误信息,或 null
->id() / ->number() Save 返回的新单内码 / 编码
->throwIfError() 不成功则抛 ApiException

默认情况下,业务错误不抛异常——想要异常就在链尾加 ->throwIfError()。传输 / 鉴权失败则会抛 (TransportException、AuthException)。

操作一览

save、batchSave、draft、view、submit、audit、unaudit、delete、 allocate、cancelAllocate、cancelAssign、push、groupSave、disassembly、 flexSave、getSysReportData、executeOperation、executeBillQuery、 billQuery、query、queryBusinessInfo、queryGroupInfo、workflowAudit、 groupDelete、switchOrg、sendMsg、attachmentUpload、attachmentDownload。

未列出的仍可通过通用入口调用:

query() 便捷方法

流式构建单据

不用手写嵌套的 Model,用构建器。基类 Entity 是 schema-free 的——任意实体、任意二开 / 扩展字段无需 SDK 支持即可使用;你也可以为某个实体写子类,获得带类型的 helper 与 IDE 补全。

或用你自己的子类(类型补全,: static 让具体类型贯穿链式调用):

mutator 语义:set/ref/custom 覆盖某个字段;line() 是唯一的追加入口; package() / 终端 $patch 对 Model 递归深合并(列表值整体替换);control() / mergePayload() 处理顶层控制位;save()/draft()/call() 是返回 Result 的终端。 设计依据见 docs/design-bill-builder.md。

配置说明

登录参数兼容性

密码模式以常见的 [acctId, userName, password, lcid] 顺序调用 AuthService.ValidateUser。 少数版本期望不同的参数列表。若你的服务端拒绝登录,请继承 SessionAuth 并覆盖 loginParameters() ——其余代码无需改动。

开发

示例在 examples/,填入凭据后即可运行。

要(重新)构建元数据层使用的清洗后实体/字段引用,把一份新的 K/3 Cloud 导出放到被 git 忽略的位置 (如 .docs/raw/)后运行:

加 --scaffold 会额外把"每个实体的起始 PHP 类"(FORM_ID + 字段名常量 + 分录 helper)生成到被 git 忽略的 .docs/scaffold/——供你拷进自己工程再编辑。--with-custom 会把二开字段也作为常量并进去; --namespace=... 指定生成的命名空间。这些都不是白名单——未知字段仍可走 ->custom()/->package()。

只有清洗后的产物(kingdee_field.standard.json、kingdee_field.custom.json、报告)会被跟踪; 原始导出永不入库。

路线图

许可

MIT —— 见 LICENSE。


All versions of k3cloud-client with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
ext-curl Version *
ext-json Version *
ext-mbstring Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package xyj2156/k3cloud-client contains the following files

Loading the files please wait ...