Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/helhum/typo3-frontend-request
https://github.com/helhum/typo3-frontend-request
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/helhum/typo3-frontend-request
- Owner: helhum
- Created: 2019-06-21T11:16:26.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-06-17T18:28:19.000Z (7 months ago)
- Last Synced: 2024-10-14T04:12:34.442Z (3 months ago)
- Language: PHP
- Size: 18.6 KB
- Stars: 15
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# TYPO3 frontend client
This package provides an API to get a response from any
TYPO3 frontend request in any context, without the need to
do an actual HTTP request.Examples:
## Doing a TYPO3 frontend request
```php
$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);
}
```## Doing a TYPO3 frontend request with a user being authenticated
```php
$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();
```