Jeanbf
Jeanbf

Reputation: 317

How can I get a request value of slim framework?

I'm working with slim framework:

This is my code:

$app->post($sPathApi.$sVersion.'subirarchivo', function () use ($app) {
    session_cache_limiter(false);
    session_start();
    if(isset($_SESSION['admin'])){
        require "controller/controllerExcel.php";
        $request = $app->request();
        $body = $request->getBody();
        print_r($request);
        //print_r($body->env['slim.request.form_hash']);
        exit();
        $aInput = json_decode($body); 
        $aGuardar = new ControllerExcel();
        header('Content-Type: application/json');
        echo json_encode($aGuardar->setDataExcel());
        exit();
    }

});

I use print_r($request);

And I print this:

enter image description here

How can I get the value of ['request']?. In the image is marked with red.

Sorry by my english.

Upvotes: 1

Views: 337

Answers (1)

Robert
Robert

Reputation: 20286

You should use

echo $this->env['slim.request.form_hash']

You can also access env by

echo  $app['environment']['slim.request.form_hash'];

Also check

http://docs.slimframework.com/environment/overview/#environment-variables

Upvotes: 1

Related Questions