Skip to content

Commit

Permalink
Fix/general fixes (#22)
Browse files Browse the repository at this point in the history
* [f#21] write server info to STDOUT -

Using `echo` would cause issues within the terminal in dev mode.

closes #21

* [ch] correct with interface to typehint on in eg's

* [f] correct how cookies are being added to the req
  • Loading branch information
NigelGreenway authored Jun 7, 2017
1 parent 2b63667 commit a507c34
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion example/app-dev-mode.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
$slim = new \Slim\App();

// Some slim configuration
$slim->get('/', function( \Psr\Http\Message\RequestInterface $req, \Psr\Http\Message\ResponseInterface $res) {
$slim->get('/', function( \Psr\Http\Message\ServerRequestInterface $req, \Psr\Http\Message\ResponseInterface $res) {

$html = <<<HTML
<html>
Expand Down
2 changes: 1 addition & 1 deletion example/app-prod-mode.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
$slim = new \Slim\App();

// Some slim configuration
$slim->get('/', function( \Psr\Http\Message\RequestInterface $req, \Psr\Http\Message\ResponseInterface $res) {
$slim->get('/', function( \Psr\Http\Message\ServerRequestInterface $req, \Psr\Http\Message\ResponseInterface $res) {

$html = <<<HTML
<html>
Expand Down
13 changes: 8 additions & 5 deletions src/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
Socket\Server as SocketServer,
Http\Server as HttpServer
};
use Slim\ {
use Slim\{
App as SlimInstance,
Http\Cookies as SlimCookies,
Http\Response as SlimResponse
};
use Zend\Diactoros\ {
Expand Down Expand Up @@ -140,7 +141,7 @@ public function run()
$request->getMethod(),
$stream,
$request->getHeaders(),
$request->getHeader('cookie'),
SlimCookies::parseHeader($request->getHeader('Cookie')[0]),
$request->getQueryParams()
);

Expand All @@ -153,13 +154,15 @@ public function run()
});

if ($this->environment !== ServerEnvironment::PRODUCTION) {
echo sprintf(
" >> Listening on http://%s:%d\n\nAssets allowed to be served: %s\n\nIn %s environment\n\n",
$output = sprintf(
" >> Listening on http://%s:%d\n\nIn %s environment\n\n",
$this->host,
$this->port,
str_replace('|', ', ', $this->whiteListedAssetFileTypes),
ServerEnvironment::getEnvironmentName($this->environment)
);
$terminal = fopen('php://stdout', 'w');
fwrite($terminal, $output);
fclose($terminal);
}

$this->loop->run();
Expand Down

0 comments on commit a507c34

Please sign in to comment.