Releases: harikt/conduit-skelton
0.7.0
This release removed attaching objects to dispatcher. So you got rid of doing
$dispatcher->setObject('blog', $di->lazyNew('Controller\Blog'));
Instead you can add to route itself as a callable or can pass the fully qualified class name.
$router = $di->get('router');
$router->add('home', '/')
->addValues(array('controller' => function ($response) {
return $response
->getBody()
->write("<p>Home page in html.</p>")
->withHeader('Content-Type', 'text/html');
}
));
$router->add('greet', '/greet')
->addValues(array(
'controller' => 'Controller\Greet',
'action' => 'hello'
));
The controller now can return string
, PSR-7 Response
object or even a Response\Payload
.
namespace Controller;
use Psr\Http\Message\ResponseInterface;
use Response\Payload;
class Blog
{
public function hello()
{
$available = array(
'text/html' => '.html',
'application/json' => '.json',
);
// $data, $view, $layout, $available
return new Payload(array('name' => 'Hari KT'), 'greet', null, $available);
}
public function returnString()
{
return "Hello World";
}
public function returnResponse(ResponseInterface $response)
{
return $response->withStatus(200)
->withHeader('Content-Type', 'text/html')
->write("returns response");
}
}
From the payload it can detect the requested content type and send the corresponding response. By default it can send html only.
Please see the tests on the usage.
0.6.0
See https://github.com/phly/conduit/releases/tag/0.14.0
- Phly\Conduit\Http\Request::getBodyParams() changed to Phly\Conduit\Http\Request::getParsedBody().
- Phly\Conduit\Http\Request::withBodyParams() changed to Phly\Conduit\Http\Request::withParsedBody().
0.5.0
0.4.1
0.4.0
0.3.1
0.3.0
When we point browser to http://localhost:8000
path is /
, and when you point to http://localhost:8000/about
, path is /about
and when pointing to http://localhost:8000/about/
is /about/
.
But $uri->getPath()
have some sort of issue, may be it relies on parse_url
and the router relies on $_SERVER['REQUEST_URI']
For details see phly/http#23 , phly/conduit#27