All Projects → lmc-eu → http-constants

lmc-eu / http-constants

Licence: MIT License
The missing PHP constants for HTTP header fields

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to http-constants

abaK
ABAP constants done right
Stars: ✭ 26 (+36.84%)
Mutual labels:  constants
guzzle-log-middleware
A Guzzle middleware to log request and responses automatically
Stars: ✭ 61 (+221.05%)
Mutual labels:  guzzle
elm-constants
Generate constant values in Elm from your environment
Stars: ✭ 42 (+121.05%)
Mutual labels:  constants
twitter-stream-api
🐤 Another Twitter stream PHP library to retrieve filtered tweets on hot.
Stars: ✭ 11 (-42.11%)
Mutual labels:  guzzle
ImHex-Patterns
Hex patterns, include patterns and magic files for the use with the ImHex Hex Editor
Stars: ✭ 192 (+910.53%)
Mutual labels:  constants
PhpBotFramework
A framework for Telegram Bot API written in PHP.
Stars: ✭ 56 (+194.74%)
Mutual labels:  guzzle
Giotto
Theme manager for your app: apply styles to anything you want through a plist file
Stars: ✭ 18 (-5.26%)
Mutual labels:  constants
ConfuserEx-Mod-By-Bed
Beds Protector | Best free obfuscation out right now
Stars: ✭ 297 (+1463.16%)
Mutual labels:  constants
behat-3-kickstart
Behat 3/Mink and Guzzle for API testing. Code follows PageObjects approach. Saucelabs integration.
Stars: ✭ 13 (-31.58%)
Mutual labels:  guzzle
guzzle6-bundle
Integrates Guzzle 6 into your Symfony application
Stars: ✭ 11 (-42.11%)
Mutual labels:  guzzle
constrandom
Macro to generate random constants in Rust https://xkcd.com/221/
Stars: ✭ 49 (+157.89%)
Mutual labels:  constants
guzzle-oauth2-subscriber
OAuth 2.0 Client for Guzzle 4, 5, 6 and 7 with PHP 5.4 - PHP 8.0 - no more dependency hell!
Stars: ✭ 112 (+489.47%)
Mutual labels:  guzzle
GuzzleBundleOAuth2Plugin
OAuth2 Plugin for GuzzleBundle
Stars: ✭ 13 (-31.58%)
Mutual labels:  guzzle
guzzle-psr18-adapter
A simple guzzle PSR-18 adapter
Stars: ✭ 13 (-31.58%)
Mutual labels:  guzzle
node-v
🔒 Secure ❄️ Synchronized ⚡️ Realtime ☁️ Cloud 🌈 Native JavaScript Variables & Events
Stars: ✭ 27 (+42.11%)
Mutual labels:  constants
php-helpers
An extensive set of PHP helper functions and classes.
Stars: ✭ 27 (+42.11%)
Mutual labels:  constants
jacky
🐄 HTTP JSON API Client for Laravel & Lumen
Stars: ✭ 17 (-10.53%)
Mutual labels:  guzzle
AkamaiOPEN-edgegrid-php-client
PHP client library for Akamai {OPEN} EdgeGrid Authentication scheme (based on Guzzle)
Stars: ✭ 38 (+100%)
Mutual labels:  guzzle
mastodon-api-php
PHP wrapper for the Mastodon API.
Stars: ✭ 12 (-36.84%)
Mutual labels:  guzzle
eventbrite
A lightweight PHP library for interacting with version 3 of the Eventbrite API.
Stars: ✭ 20 (+5.26%)
Mutual labels:  guzzle

HTTP Header Fields Constants for PHP

Latest Stable Version GitHub Actions Build Status Total Downloads

The missing PHP constants definition for header fields of your HTTP requests and responses.

Stop repeating string identifiers and placing typos of HTTP headers in your code!

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

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

Install

$ composer require lmc/http-constants

Note you will need to have Composer installed to do this.

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.

License

The library is open source software licensed under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].