How to save Request object?

#1

To store Request object to file or db,I tried below

$object = serialize($request);

but Slim framework notice me error message like below

Details

Type: Exception

Message: Serialization of ‘Closure’ is not allowed

File: /var/www/myapp/public/index.php
Line: 51

I’m beginner for PHP, I tried googling but I couldn’t understatnd and not solved yet :frowning:
Anybody How to solve it?

#2

Why would you want to store it? It’s not something that should be stored. Maybe I’m not understanding the problem that you’re trying to solve

#3

hmm… I’m building Rest API Debugging server,
My server just echo what HTTP packets been sent by user web browser or Other Rest API server, but Requested all packets should be stored to Database

Actually, I can solve by calling all functions in Request object, but I want to save all Request packet contents without Parsing or Calling Request object API :smile:

#4

Perhaps worth using middleware ?

    $app->add(function ($req, $res, $next) {

        $res = $next($req, $res);

        //Do your logging things here

        return $res;

    });
#5

Right!

My source like below

$app->any('/[{params:.*}]', function(Request $request,Response $response, array $args) {
    $query = "INSERT INTO ssrf(content,date,user) VALUES (?,?,?)";
    $db = db_init();
    $method = $request->getMethod();
    $params = $request->getUri()->getQuery();
    $uri = $request->getUri();
    $headers = $request->getHeaders();
    $body = $request->getBody();
    # Insert to MySQL,Entire request object
    # I don't know how to strore all elements to DB in Request object...
   
    });

Ofcourse ,I could solve by storing text with parsed object but I want to save “all” it include the raw data object, not just text