简体   繁体   中英

Returning status code in laravel

I am a total noob at Laravel

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

What I want to do is return the response text and a status code, 500, how can I do this?

This is how you send a 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);
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM