在laravel中返回状态代码

时间:2014-02-28 01:19:07

标签: http exception laravel response status

我是Laravel的总菜鸟

public function stageFiles($user, $project) {
    try
    {
        $path = Input.get("item");
    } 
    catch (Exception $e)
    {
        $exceptionMessage = $e->getMessage();
        $responseText = json_encode($exceptionMessage);
    }
}

我想要做的是返回响应文本和状态代码,500,我该怎么做?

1 个答案:

答案 0 :(得分:0)

这是你发送500的方式:

public function stageFiles($user, $project) {
    try
    {
        $path = Input.get("item");
    } 
    catch (Exception $e)
    {
        $exceptionMessage = $e->getMessage();
        $responseText = json_encode($exceptionMessage);

        return Response::make($responseText, 500);
    }
}