PHP code example of spaceonfire / restify

1. Go to this page and download the library: Download spaceonfire/restify library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

spaceonfire / restify example snippets



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;
}

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'];
});