onlyoffice/docs-integration-sdk
Composer 安装命令:
composer require onlyoffice/docs-integration-sdk
包简介
ONLYOFFICE Docs integration SDK
关键字:
README 文档
README
ONLYOFFICE Docs Integration PHP SDK provides common interfaces and default implementations for integrating ONLYOFFICE Document Server into your own website or application on PHP.
Prerequisites
- PHP: version 7.4.0 and higher
Managers
| Manager | Description | Default implementation |
|---|---|---|
| DocumentManagerInterface | This manager is used for working with files, and string data associated with documents. | DocumentManager (abstract) |
| FormatsManagerInterface | This manager is used for working with document formats. | FormatsManager |
| JwtManagerInterface | This manager is used for generating and verifying authorization tokens. | JwtManager (abstract) |
| SettingsManagerInterface | This manager is used to manage integration application settings. | SettingsManager (abstract) |
Services
| Service | Description | Default implementation |
|---|---|---|
| CallbackServiceInterface | This service is used for processing the response of the Document Server. | CallbackService (abstract) |
| DocEditorConfigServiceInterface | This configuration generation service is used for opening the document editor. | DocEditorConfigService |
| RequestServiceInterface | This service is used to make requests to the ONLYOFFICE Document Server. | RequestService (abstract) |
Usage
- Implement the methods of the abstract DocumentManager class:
public function getDocumentKey(string $fileId, bool $embedded = false) { return self::generateRevisionId($fileId); } public function getDocumentName(string $fileId) { return "sample.docx"; } public static function getLangMapping() { return null; } public static function getFileUrl(string $fileId) { return "https://example-server.example/fileId/download/"; } public static function getCallbackUrl(string $fileId) { return "https://example-server.example/callback"; } public static function getGobackUrl(string $fileId) { return "https://example-server.example/filelist"; } public static function getCreateUrl(string $fileId) { return "https://example-server.example/fileId"; }
- Implement the methods of the abstract JwtManager class (use third-party libraries for JWT encoding and decoding, whichever is convenient for you):
public function encode($token, $key, $algorithm = "HS256") { return "SOME.JWT.STRING"; } public function decode($token, $key, $algorithm = "HS256") { return json_encode([]); }
- Implement the methods of the abstract SettingsManager class:
public function getServerUrl() { return "https://example-server.example/"; } public function getSetting($settingName) { return null; } public function setSetting($settingName, $value, $createSetting = false) { // if ($createSetting === true) { // $this->yourMethodForCreateNewSetting($settingName, $value); // return; // } // $this->yourMethodForSetNewValueForSetting($settingName, $value); }
- Implement the methods of the abstract SettingsManager class:
public function processTrackerStatusEditing() { // $someTrackResult["error"] = 0; // return json_encode($someTrackResult); } public function processTrackerStatusMustsave() { // $someTrackResult["error"] = 0; // return json_encode($someTrackResult); } public function processTrackerStatusCorrupted() { // $someTrackResult["error"] = 0; // return json_encode($someTrackResult); } public function processTrackerStatusClosed() { // $someTrackResult["error"] = 0; // return json_encode($someTrackResult); } public function processTrackerStatusForcesave() { // $someTrackResult["error"] = 0; // return json_encode($someTrackResult); }
- Create a class that implements the HttpClientInterface interface (use PHP Client URL Library or any other third-party library to make requests):
class YourHttpClient implements HttpClientInterface { public function __construct() { $this->responseStatusCode = null; $this->responseBody = null; } public function getStatusCode() { return $this->responseStatusCode; } public function getBody() { return $this->responseBody; } public function request($url, $method = 'GET', $opts = []) { $this->responseStatusCode = 200; $this->responseBody = "{\"status\": \"OK\"}"; } }
- Implement the method of the abstract RequestService class:
public function getFileUrlForConvert() { return "https://example-server.example/file-url-for-check-convert"; }
- Use DocEditorConfigService to create a config model for the editors in your own controllers.
onlyoffice/docs-integration-sdk 适用场景与选型建议
onlyoffice/docs-integration-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 87.81k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2024 年 09 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「sdk」 「docs」 「onlyoffice」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 onlyoffice/docs-integration-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 onlyoffice/docs-integration-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 onlyoffice/docs-integration-sdk 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Bookdown.io With Bootswatch Styles And Prism Syntax Highlighting
Api documentation generator for Laravel 5
Replacement for Swagger. It is built for Laravel
Laravel API documentation generating tool
The StyleCI Docs
A tool for display docs or api docs to others
统计信息
- 总下载量: 87.81k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2024-09-20