witooh / message
此包的最新版本(dev-master)没有可用的许可信息。
dev-master
2013-07-14 17:57 UTC
Requires
- php: >=5.3.0
- illuminate/support: 4.0.x
This package is not auto-updated.
Last update: 2024-09-23 14:19:34 UTC
README
#Laravel Message#
##安装##
在app.config中添加
return array( 'providers'=>array( ... ... 'Witooh\Message\MessageServiceProvider', ), 'alias'=>array( ''' ... 'Message' => 'Witooh\Message\Facades\Message', ), );
##用法##
###消息###
消息将生成JSON消息数据
public function getIndex(){ return Response::json(Message::success($data, $header); }
响应将如下所示
{ header:{ status: 200, message: 'success' }, body:[ {id: 1, name: 'test1'}, {id: 2, nmae: 'test2'} ] }
向JSON响应抛出错误异常
public function testExceptioons() { throw new PermissionException(Message::permission($message)); throw new AuthenticateException(Message::auth($message)); throw new NoutFoundException(Message::notfound($message)); throw new ValidationException(Message::validation($errors)); }