PHP code example of helhum / typo3-frontend-request

1. Go to this page and download the library: Download helhum/typo3-frontend-request 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/ */

    

helhum / typo3-frontend-request example snippets


$request = new \TYPO3\CMS\Core\Http\ServerRequest($uri);
$client = new \Helhum\Typo3FrontendRequest\Typo3Client();
try {
    $response = $client->send($request);
    $body = (string)$response->getBody();
} catch (\Helhum\Typo3FrontendRequest\RequestFailed $e) {
    throw new \RuntimeException('Could not fetch  page "' . $uri . '", reason: ' . $e->getMessage(), 1552081550, $e);
}

$request = new \TYPO3\CMS\Core\Http\ServerRequest($uri)
$request = $request->withHeader(
    'x-typo3-frontend-user',
    (string)$context->getPropertyFromAspect('frontend.user', 'id')
);
$client = new \Helhum\Typo3FrontendRequest\Typo3Client();
$response = $client->send($request);
$body = (string)$response->getBody();