Skip to content

Instantly share code, notes, and snippets.

@Yrwein
Created February 13, 2020 15:51
Show Gist options
  • Save Yrwein/dce2c81c3ac9df5c3a8d0b92211ba8c3 to your computer and use it in GitHub Desktop.
Save Yrwein/dce2c81c3ac9df5c3a8d0b92211ba8c3 to your computer and use it in GitHub Desktop.
POC for stackoverflow.com/questions/60169581
<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
use \Psr\Container\ContainerInterface;
require './vendor/autoload.php';
class TypeHintTestController {
private $container;
public function __construct(ContainerInterface $container) {
$this->container = $container;
}
public function index(Request $request, Response $response, array $args) {
$response->getBody()->write("From: " . get_class($this->container));
return $response;
}
}
$app = new \Slim\App;
$app->get('/', '\TypeHintTestController:index');
$app->run();
@Albertcuicas
Copy link

it works, thank you‼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment