guancheng / msgpack
rybakit/msgpack 的 lumen API 响应包装器。
0.2
2017-06-02 02:18 UTC
Requires
- php: >=5.5.9
- illuminate/http: ~5.3
- illuminate/support: ~5.3
- rybakit/msgpack: ^0.2.2
- symfony/http-kernel: ~2.7|~3.0
Requires (Dev)
- illuminate/routing: ~5.3
- mockery/mockery: ~0.9
- phpunit/phpunit: ~4.0
- vlucas/phpdotenv: ~2.0
This package is auto-updated.
Last update: 2024-09-16 19:16:44 UTC
README
rybakit/msgpack 的 lumen API 响应包装器。
安装
composer require guancheng/msgpack
或
clone / download this repo
使用
响应
use Illuminate\Routing\Controller;
use LGC\Msgpack\MsgpackResponse;
class TestController extends Controller
{
public function test()
{
return new MsgpackResponse([
'success' => true
]);
}
}
如果你想要返回 Arrayable 对象,直接这样做!
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'
])
]);
}
}
当使用 Arrayable 类型时,请注意:由于我们没有记住打包的数据类型,所以 getData() 总是返回数组。
测试
use LGC\Msgpack\MsgpackConcern;
class TestApiTest extends PHPUnit_Framework_TestCase
{
use MsgpackConcern;
public function testShouldSeeMsgpack()
{
$this->shouldSeeMsgpack();
}
}
开发
clone the repo
composer install
路线图
制作其他 Laravel 数据类型转换器。
许可
MIT
在 Beerpay 上支持
嘿,兄弟!帮我来点 🍻!