Skip to content
/ msgpack Public

The lumen api response wrapper for rybakit/msgpack.

License

Notifications You must be signed in to change notification settings

sc0Vu/msgpack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

msgpack

Build Status codecov Dependency Status License

The lumen api response wrapper for rybakit/msgpack.

Install

composer require guancheng/msgpack

or

clone / download this repo

Usage

Response

use Illuminate\Routing\Controller;
use LGC\Msgpack\MsgpackResponse;

class TestController extends Controller
{
    public function test()
    {
        return new MsgpackResponse([
            'success' => true
        ]);
    }
}

If you want to return Arrayable object, just do it!

use Illuminate\Support\Collection;
use Illuminate\Routing\Controller;
use LGC\Msgpack\MsgpackResponse;

class TestController extends Controller
{
    public function test()
    {
        return new MsgpackResponse([
            'success' => true,
            'data' => new Collection([
            	'hello' => 'lumtify'
            ])
        ]);
    }
}

When use arrayable types you have to notice: due to we don't remember pack data type, so the getData() always return array

Test

use LGC\Msgpack\MsgpackConcern;

class TestApiTest extends PHPUnit_Framework_TestCase
{
    use MsgpackConcern;

    public function testShouldSeeMsgpack()
    {
    	$this->shouldSeeMsgpack();
    }
}

Development

clone the repo

composer install

Roadmap

Make other laravel data type transformer.

Licence

MIT

Support on Beerpay

Hey dude! Help me out for a couple of 🍻!

Beerpay Beerpay