Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Http response code enums in PHP

Tags:

php

laravel

I'm looking for something like HttpResponseCode::FileNotFound => 404, HttpResponseCode::OK => 200

I've searched for "php http status codes list", "php http status codes enum" and couldnt find anything.

like image 992
mrwaim Avatar asked May 30 '15 14:05

mrwaim


People also ask

How do I get HTTP response in PHP?

For PHP versions 4.0: In order to send the HTTP response code, we need to assemble the response code. To achieve this, use header() function. The header() function contains a special use-case which can detect a HTTP response line and replace that with a custom one. header( "HTTP/1.1 404 Not Found" );

How do you set a status code in HTTP response?

Occasionally, you may need to set a different status code on the response from your Servlet. To set a different HTTP status code from your Servlet, call the following method on the HttpServletResponse object passed in to your server: res. setStatus(nnn);

What is HTTP response?

An HTTP response is made by a server to a client. The aim of the response is to provide the client with the resource it requested, or inform the client that the action it requested has been carried out; or else to inform the client that an error occurred in processing its request.


1 Answers

The term to search for is "php http status codes const" which leads you to http://symfony.com/blog/new-in-symfony-2-4-using-constants-for-http-status-code - It has \Illuminate\Http\Response::HTTP_NOT_FOUND and \Illuminate\Http\Response::HTTP_OK

etc.

List is here - https://github.com/symfony/HttpFoundation/blob/master/Response.php

like image 175
mrwaim Avatar answered Oct 22 '22 17:10

mrwaim