PHP code example of titaniumcodes / middleware-msgpack

1. Go to this page and download the library: Download titaniumcodes/middleware-msgpack library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

titaniumcodes / middleware-msgpack example snippets



y = new \Slim\Http\Body(fopen('php://temp', 'r+')); //empty body for new response, can be replaced with any other implementation of PSR-7 StreamInterface
$config = [
    'config_dir' => __DIR__.'/config',
    'settings' => [
        'displayErrorDetails' => true,

        'logger' => [
            'name' => 'slim-app',
            'path' => __DIR__ . '/../logs/app.log',
        ],
    ],
];

$app = new \Slim\App($config);
$app->add(new \TitaniumCodes\Middleware\Msgpack($body, 'application/x-msgpack'));
$app->get('/', function ($request, $response, $args) use($config) {
    return $response->withJson($config);
});
$app->run();


return [
    'body' => new \Slim\Http\Body(fopen('php://temp', 'r+'));
    'content-type' => 'application/x-msgpack',
];


return [
    //...
    'providers' => [
        '\TitaniumCodes\Middleware\MsgpackProvider',
        //...
    ],
    'middlewares' => [
        'msgpack_middleware',
        //...
    ],
];