Slim 3.3 truncates output

I’m trying to get Slim to run on my Windows 7 system.
So far I’ve gotten everything installed with Composer but when I run a very simple program, the output is not as intended.

Below is my code:

<?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); use Slim\App; use Slim\Http\Request; use Slim\Http\Response; require '../vendor/autoload.php'; $app = new App; $app->get('/', function (Request $in, Response $out, $args) { return $out->write("xxxxx"); }); $app->run(); I am expecting output "xxxxx", instead i get "x". This means I loose 4 characters somewhere. Running PHP 5.5.12 The encoding is UTF-8 (not BOM) When i run "curl -v http://localhost:8080/" I get D:\wamp\www\slim_test\src\public>curl -v http://localhost:8080/ * Trying 127.0.0.1... * Connected to localhost (127.0.0.1) port 8080 (#0) > GET / HTTP/1.1 > Host: localhost:8080 > User-Agent: curl/7.46.0 > Accept: */* > < HTTP/1.1 200 OK < Host: localhost:8080 < Connection: close < X-Powered-By: PHP/5.5.12 < Content-Type: text/html; charset=UTF-8 < Content-Length: 5 < x* Closing connection 0 I'd appreciate your help. EDIT Once i append these lines of code to the end of the file, the response is correct. $response = $app->run(true); //Silent mode, wont send the response $response = $response->withoutHeader("Content-Length"); //Remove the Content-Length $app->respond($response); //Now we send the response I cannot figure out why.....?

I get “xxxxx” on my machine. Is there any whitespace before the <?php tag?

1 Like

Hi llvdl,

I already implemented a workaround for this issue.
After your comment I went back over my problem code…I found 2 extra lines above my <?php tag…
After removing them it worked as intended.
Thank you so much for even looking at this thread after so long.
Have a great week!