PHP code example of koriym / http-constants

1. Go to this page and download the library: Download koriym/http-constants library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

koriym / http-constants example snippets



use Koriym\HttpConstants\HttpStatusCode;
use Koriym\HttpConstants\RequestHeader;
use Koriym\HttpConstants\ResponseHeader;
use Koriym\HttpConstants\MediaType;
use Koriym\HttpConstants\Method;

http_response_code(StatusCode::BAD_REQUEST);
header(ResponseHeader::CONTENT_TYPE . ': ' . MediaType::APPLICATION_JSON_API);
// Content-Type: application/vnd.api+json
header(ResponseHeader::CACHE_CONTROL . ': max-age=3600');
// Cache-Control: max-age=3600