Download the PHP package gasparyanyur/http without Composer

On this page you can find all versions of the php package gasparyanyur/http. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package http

sabre/http

This library provides a toolkit to make working with the HTTP protocol easier.

Most PHP scripts run within a HTTP request but accessing information about the HTTP request is cumbersome at least.

There's bad practices, inconsistencies and confusion. This library is effectively a wrapper around the following PHP constructs:

For Input:

For output:

What this library provides, is a Request object, and a Response object.

The objects are extendable and easily mockable.

Build status

branch status
master Build Status
4.2 Build Status
3.0 Build Status

Installation

Make sure you have composer installed. In your project directory, create, or edit a composer.json file, and make sure it contains something like this:

After that, just hit composer install and you should be rolling.

Quick history

This library came to existence in 2009, as a part of the sabre/dav project, which uses it heavily.

It got split off into a separate library to make it easier to manage releases and hopefully giving it use outside of the scope of just sabre/dav.

Although completely independently developed, this library has a LOT of overlap with Symfony's HttpFoundation.

Said library does a lot more stuff and is significantly more popular, so if you are looking for something to fulfill this particular requirement, I'd recommend also considering HttpFoundation.

Getting started

First and foremost, this library wraps the superglobals. The easiest way to instantiate a request object is as follows:

This line should only happen once in your entire application. Everywhere else you should pass this request object around using dependency injection.

You should always typehint on it's interface:

A response object you can just create as such:

After you fully constructed your response, you must call:

This line should generally also appear once in your application (at the very end).

Decorators

It may be useful to extend the Request and Response objects in your application, if you for example would like them to carry a bit more information about the current request.

For instance, you may want to add an isLoggedIn method to the Request object.

Simply extending Request and Response may pose some problems:

  1. You may want to extend the objects with new behaviors differently, in different subsystems of your application,
  2. The Sapi::getRequest factory always returns a instance of Request so you would have to override the factory method as well,
  3. By controlling the instantation and depend on specific Request and Response instances in your library or application, you make it harder to work with other applications which also use sabre/http.

In short: it would be bad design. Instead, it's recommended to use the decorator pattern to add new behavior where you need it. sabre/http provides helper classes to quickly do this.

Example:

Our application assumes that the true Request object was instantiated somewhere else, by some other subsystem. This could simply be a call like $request = Sapi::getRequest() at the top of your application, but could also be somewhere in a unittest.

All we know in the current subsystem, is that we received a $request and that it implements Sabre\HTTP\RequestInterface. To decorate this object, all we need to do is:

And that's it, we now have an isLoggedIn method, without having to mess with the core instances.

Client

This package also contains a simple wrapper around cURL, which will allow you to write simple clients, using the Request and Response objects you're already familiar with.

It's by no means a replacement for something like Guzzle, but it provides a simple and lightweight API for making the occasional API call.

Usage

The client emits 3 event using sabre/event. beforeRequest, afterRequest and error.

Asynchronous requests

The Client also supports doing asynchronous requests. This is especially handy if you need to perform a number of requests, that are allowed to be executed in parallel.

The underlying system for this is simply cURL's multi request handler, but this provides a much nicer API to handle this.

Sample usage:

Check out examples/asyncclient.php for more information.

Writing a reverse proxy

With all these tools combined, it becomes very easy to write a simple reverse http proxy.

The Request and Response API's

Request

Response

Made at fruux

This library is being developed by fruux. Drop us a line for commercial services or enterprise support.


All versions of http with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4
ext-mbstring Version *
ext-ctype Version *
sabre/event Version >=1.0.0,<4.0.0
sabre/uri Version ~1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package gasparyanyur/http contains the following files

Loading the files please wait ....