1. Go to this page and download the library: Download bnf/slim-typo3 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/ */
declare(strict_types=1);
namespace Your\Namespace;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\App;
use TYPO3\CMS\Core\SingletonInterface;
class TestApp implements SingletonInterface
{
public function __invoke(App $app)
{
$app->add(function (Request $request, Response $response, callable $next) {
$response->getBody()->write('I am middleware.. ');
return $next($request, $response, $next);
});
$app->get('/bar[/{foo}]', static::class . ':bar');
}
public function bar(Request $request, Response $response): Response
{
$response->getBody()->write('baz');
$foo = $request->getAttribute('foo');
if ($foo) {
$response->getBody()->write(' ' . htmlspecialchars($foo));
}
return $response;
}
}
// Will implicitly call `new \Your\Namespace\Middleware\Foo($container)`
// when the middleware is executed.
$app->add(\Your\Namespace\Middleware\Foo::class);
// or ('view' needs to be defined in the container)
$app->add('view');
// You SHOULD NOT do this
$app->add(new \Your\Namespace\Middleware\Foo::class);
// nor this
$app->add($container->get(\Your\Namespace\Middleware\Foo::class));
// nor this
$app->add($container->get('view'));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.