Download the PHP package legionth/http-rest without Composer

On this page you can find all versions of the php package legionth/http-rest. 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-rest

REST HTTP Server

Creating ReactPHP HTTP Server but with REST

Table of Contents

Example

This is an HTTP server which responds with an hello in every request on <address>/say/hello.

Every other call will result in an 404 response.

Make sure the callback function has 2 parameters. The first parameter is always the PSR-7 request object. The second parameter is the next endpoint defined in your API. If no next function is given it will be the default function of the server which will respond with will create an 404 error by default.

Usage

Server

The Server uses the ReactPHP HTTP Server and uses its internal implemented middleware

Every endpoint is added as a middleware, therefor a request will pass every function sequentially. The second parameter (defined as $next in these examples) can be used to pass the request to following endpoint.

Dynamic Values

To add dynamic values in the REST API definition the operator : can be used

Now a HTTP client can call the address e.g. http://localhost:8080/say/hello. The key word and value hello will be stored in the third parameter of the callback function.

There is no type check her that can validate which API should be used. /say/:word and/say/:number would be the same. In this case the order of your API definition matters.

Default Callback

A default callback can be defined in the listen method. This method will be used if no definition can be found.

By default this library will respond with an 404 HTTP response.

Parameter Placeholder

As seen in the previous chapter you can use the : to mark dynamic values. Instead of using this strategy, to mark dynamic parameters, this library supports additional strategies via different classes:

Checkout the examples for more information.

Install

The recommended way to install this library is through Composer. New to Composer?

This will install the latest supported version:

License

MIT


All versions of http-rest with dependencies

PHP Build Version
Package Version
Requires react/http Version ^0.8.3
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 legionth/http-rest contains the following files

Loading the files please wait ....