Is this normal? Would anyone be willing to test this, please?

Hi guys, could someone please do me a favour?

Do a clean install of Slimframework through composer, as per usual.

Put the this basic app inside your main index.php file

<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;

require 'vendor/autoload.php';

$app = new \Slim\App;
$app->get('/hello/{name}', function (Request $request, Response $response) {
    var_dump($request); die;

});
$app->run();

The file will obviously dump $request to the browser. Copy the dump into a .txt file and check how large it is.

Mine is 42kb, and it seems to have about 9 instances of roughly the same SERVER_* type data.

Is this normal?

I know 42kb isn’t that much, but my actual problem is that I have built a fairly basic User Login/Register system, using some validation/Amazon SES/Paypal plugins pulled in via composer.

Whenever I now var_dump($request) inside a Controller method, IT IS 1.4mb !!! That seems rediculous! This can’t be normal, right?

Please let me know what your results are? And if possible, what could be causing this on my side?

I am running Ubuntu 16.04, PHP7, latest Apache and MySQL.

Many thanks!

Mine was 85KB, decoded. I’d take a guess that the repeating elements are due to the Request object being immutable? I don’t really know.

This is definitely an environment/configuration problem on your end.

I don’t even know why you are dumping request as it’s not a valid metric to begin with.

Slim’s outputs are whatever you tell it to output.

$response->write('a') => Content Length of 1.

Thanks for the reply, guys!

@geggleto It most likely is an environmental problem, yes. I’m going to set up ubuntu on a VPS, and test it all again.

I’m not too sure why you are referring to $response though? I’m referring to $request.

So, are you saying that it should not be a problem with regards to server resources having a 1mb+ $request variable being ‘passed around’ for each user instance on my site? To me it seems like it should be a big problem. But like I said, i’ll test it on a clean install on a VPS and see how that goes :slight_smile:

So I tried it (in my own webapp, not in a virgin-app)
I see 5 times: Slim\Http\Environment, inside pimple/container, which happens to have the request inside as well.

For me: that’s like 4 times too much of the same.
But it can be the cause of dumping the thing in the first place, but it could also mean that the Slim\App (somewhere at the top_ holds it’s information in a weird way. (and I’m not the one who can tell you this)

Pimple should only hold 1 reference to an object.