b13 / slimphp-bridge Goto Github PK
View Code? Open in Web Editor NEWSlimPHP Integration in TYPO3 Frontend for rapid API development
License: GNU General Public License v2.0
SlimPHP Integration in TYPO3 Frontend for rapid API development
License: GNU General Public License v2.0
Hi, @bmack as mentioned on T3DD it'd be great to have a new tag to avoid nasty @dev
composer requirements in TYPO3 CMS 12.4 LTS production systems. Afais everything is up and running, only tag is missing and eventually merge of latest PR.
Thanks in advance!
Hello
On a TYPO3 10.4, I've just updated b13/slimphp-bridge
to 0.4.0 with composer update -W b13/slimphp-bridge
.
The version of slim raised (because of -W) from 4.8.1 to 4.10.0, but this new version of slim does not autodetect guzzlehttp/psr7 1.x anymore.
(1/1) RuntimeException
Could not detect any PSR-17 ResponseFactory implementations. Please install a supported implementation in order to use `AppFactory::create()`. See https://github.com/slimphp/Slim/blob/4.x/README.md for a list of supported implementations.
I had to require sapphirecat/slim4-http-interop-adapter
in order to get things right again.
See their README for a detailed explanation.
Because typo3/cms-core
10.4 requires guzzlehttp/psr7:^1.8.5
(11.5+ allows guzzlehttp/psr7:^1.8.5 || ^2.1.2
), I think sapphirecat/slim4-http-interop-adapter
should also require for b13/slimphp-bridge
With routeCollector available in Slim controller we could easily create an index endpoint that lists all available slim api routes with their properties. Currently I see no way to access the routeCollector from the api callback without using reflection.
I run a TYPO3 V11 on aPHP 8.1 machine, and tried to port my REST API to the slimphp-bridge
.
Unfortunatly the user version nyholm/psr7-server
is quite old and is not compatible with PHP 8. As far as I can see, the lib is used in the unit tests.
Would it be possible to raise the version of nyholm/psr7-server
to at least 1.0.1
which added PHP 8 support?
Having the following site config, leads to an "#404 Slim\Exception\HttpNotFoundException" error
routes:
-
prefix: /api
groups:
-
routePath: /v1/de
routes:
-
methods:
- get
routePath: /locations
callback: 'Cp\WmdTemplate\Controller\AjaxController:filteredLocationsAction'
-
route: robots.txt
type: staticText
content: "User-agent: *\r\nDisallow: /typo3/\r\nAllow: /typo3/sysext/frontend/Resources/Public/*\r\n"
Exception:
Call to a member function getSetupArray() on null in /var/www/html/src/autotypo/vendor/typo3/cms-extbase/Classes/Configuration/FrontendConfigurationManager.php line 193
Configuration:
services:
VENDOR\Myext\Controller\TestController:
public: true
Middlewares in route config: only B13\SlimPhp\Middleware\ExtbaseBridge
The Attribute "frontend.typoscript" is not set at this moment
strtolower(): Argument #1 ($string) must be of type string, TYPO3\CMS\Core\Localization\Locale given
in vendor/b13/slimphp-bridge/src/Service/RequestedLanguageToSiteLanguageResolverService.php line 36
is thrown, if B13\SlimPhp\Middleware\PreferredClientLanguageSelector middleware is set.
This is caused by resolved https://forge.typo3.org/issues/99812.
A type-cast to string is required.
[$locale] = explode('.', strtolower((string)$language->getLocale()));
Make it possible to use that package with TYPO3 v12.
Hi hi
If I call a non existing route, Slim throws a HttpNotFoundException, but TYPO3 does not catch it, and the client finally gets a 500.
I would like to better handle Slim errors, maybe like that:
// in \B13\SlimPhp\Middleware\SlimInitiator::process
try {
return $app->handle($request);
} catch (HttpException $e) {
$errorController = GeneralUtility::makeInstance(ErrorController::class);
return match ($e->getCode()) {
503 => $errorController->unavailableAction($request, $e->getMessage()),
500 => $errorController->internalErrorAction($request, $e->getMessage()),
404 => $errorController->pageNotFoundAction($request, $e->getMessage()),
403 => $errorController->accessDeniedAction($request, $e->getMessage()),
default => throw $e,
};
}
It's better because the configured TYPO3 errorHandlers will be triggered.
One thing it's not cool, it is that the content-type of the request is not properly detected (html response instead of a json response).
What do you think @bmack ?
I want to create a Slim callback that in some cases does nothing - in this case the calling middleware handler should keep on going. SlimInitiator could check for a special Slim callback response (NoOp) to handle that case.
With PHP 8.1 there is the error Undefined global variable $TSFE
when calling the API endpoint and using the ExtbaseBridge middleware.
In the readme it is stated that "The prefix value enables a SlimPHP Application", but in
prefix gets a default value. So if you have an additional route (like a static route for robots.txt), SlimInitiator will try to init a Slim Route which leads to route status RoutingResults::NOT_FOUND.Typical PHP v8 warning
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.