spaceonfire / restify
Bitrix REST API module
Installs: 30
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 3
Open Issues: 0
Type:bitrix-d7-module
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
Модуль, который позволяет с легкостью создавать REST API для 1С-Битрикс
Начало работы
Необходимые условия окружения
Для запуска проекта в системе должны быть установлены:
- PHP >= 7
- Composer
Установка
composer require spaceonfire/restify
Examples
Events
API output transformation
<?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; }
Build full path to image in 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']; });