2017 © Pedro Peláez
 

library http-constants

HTTP Header Fields Constants

image

lmc/http-constants

HTTP Header Fields Constants

  • Wednesday, February 21, 2018
  • by OndraM
  • Repository
  • 4 Watchers
  • 5 Stars
  • 2,680 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 53 % Grown

The README.md

HTTP Header Fields Constants for PHP

Latest Stable Version GitHub Actions Build Status Total Downloads, (*1)

The missing PHP constants definition for header fields of your HTTP requests and responses., (*2)

Stop repeating string identifiers and placing typos of HTTP headers in your code!, (*3)

Could be used when interacting with headers using pure PHP, Guzzle, Symfony HttpFoundation, Zend HTTP, Zend Diactoros etc., (*4)

Contains all ~200 constants for headers defined in IANA list (both Permanent and Provisional) and some common non-standard headers based on Wikipedia list., (*5)

Install

$ composer require lmc/http-constants

Note you will need to have Composer installed to do this., (*6)

Usage

<?php

namespace My;

use Lmc\HttpConstants\Header;

class Example
{
    public function exampleWithGuzzle()
    {
        $client = new \GuzzleHttp\Client();

        $response = $client->request(
            'GET',
            'https://api.foo/bar',
             ['headers' => [Header::ACCEPT_ENCODING => 'gzip']]
       );

        echo $response->getHeaderLine(Header::CONTENT_TYPE);
    }

    public function exampleWithSymfonyHttpFoundation()
    {
        $response = new \Symfony\Component\HttpFoundation\Response();

        $response->headers->set(Header::ACCESS_CONTROL_ALLOW_ORIGIN, 'www.jobs.cz');
    }

    public function exampleWithPurePhp()
    {
        header(Header::CONTENT_TYPE . ': application/pdf');
        header(Header::CACHE_CONTROL .  ': no-cache, must-revalidate');
    }
}

Changelog

For latest changes see CHANGELOG.md file. We follow Semantic Versioning., (*7)

License

The library is open source software licensed under the MIT license., (*8)

The Versions

21/02 2018

dev-master

9999999-dev

HTTP Header Fields Constants

  Sources   Download

MIT

The Requires

  • php ^7.0

 

http request response constants

21/02 2018

1.0.0

1.0.0.0

HTTP Header Fields Constants

  Sources   Download

MIT

The Requires

  • php ^7.0

 

http request response constants

05/12 2017

dev-feature/php7

dev-feature/php7

HTTP Header Fields Constants

  Sources   Download

MIT

The Requires

  • php ^7.0

 

http request response constants

24/07 2017

0.2.0

0.2.0.0

HTTP Header Fields Constants

  Sources   Download

MIT

http request response constants

24/07 2017

0.1.0

0.1.0.0

HTTP Header Fields Constants

  Sources   Download

MIT

http request response constants