spaceonfire / restify
此包已被 放弃 并且不再维护。未建议替代包。
Bitrix REST API 模块
1.0.0-beta.2
2018-12-11 16:14 UTC
Requires
- ext-json: *
- composer/installers: ~1.0
- emonkak/http-exception: ^2.0.0
- erusev/parsedown: 1.8.0-beta-5
- mikecao/flight: ^1.3.0
- spaceonfire/bmf: 1.0.0-beta.6
Requires (Dev)
- phpunit/phpunit: 5.2.*
This package is auto-updated.
Last update: 2023-08-16 01:29:42 UTC
README
一个允许轻松创建 1C-Битрикс REST API 的模块
开始使用
所需环境条件
为了在系统中运行此项目,以下软件必须已安装:
- PHP >= 7
- Composer
安装
composer require spaceonfire/restify
示例
事件
API 输出转换
<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_before.php'; use Bitrix\Main\Event; use Bitrix\Main\EventManager; use Emonkak\HttpException\InternalServerErrorHttpException; EventManager::getInstance()->addEventHandler( 'spaceonfire.restify', 'transform', 'modifyStatusCode' ); function throw500() { throw new InternalServerErrorHttpException(); } function modifyStatusCode(Event $event) { $params = $event->getParameters(); $params['statusCode'] = 500; }
在 FileFormatter 中构建图像的完整路径
use Bitrix\Main\Event; use Bitrix\Main\EventManager; EventManager::getInstance()->addEventHandler('spaceonfire.restify', 'OnFileFormatter', function(Event $event) { $params = $event->getParameters(); $params['data']['SRC'] = $_SERVER['REQUEST_SCHEME'] . '://' . (env('DOMAIN') ?: $_SERVER['HTTP_HOST']) . $params['data']['SRC']; });