Download the PHP package patrick-barreto/http without Composer

On this page you can find all versions of the php package patrick-barreto/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

About Package

This package gonna make all the essential HTTP ressources for your API projetc.

How to install

How to Use

Important: Make sure that in your server configuration file you are redirecting all requests to index.php.

Basically you will use the Http abstration to manipulate all ressources from this package.

Roates

Important: For the same http method declaration, the routes order must be:


Middlewares

Create a middleware

You need to import Middleware Interface to certificate that you were implemented a valid Middleware sintaxe for system.

Your middleware must be a class like this:

Important: This is the instance of request that you can manipulate and insert information from your system. This instance is accessible for you in the callback function parameter that you need to pass in the routes.

Use yours middlewares

To use your middlewares you need to fill the system with theirs namespaces and inform if the execution is default or not.

Add new middleware namespace to middlewares namespaces map

Default middlewares are executed for all routes.

important: Like the routes, the order of default middlewares declaration are very important. It will be the execution order. For middlewares not default, to use them you need to inform the name of middleware, in execution order to be executed after default middlewares.


Response

To send a response for anyone request you cant use Http::response, the method have default values for default responses.


Request Class

The Request Class store usefull data from the request. This informations are static and acessible in anywhere in your sistem.

During the middlewares you can increment your personal data into request intance class that will be give to you in callback param on routes declaration, where you will pass to your controller all request or specfic data.

Your specific data will not be a static data, will be a instance data. The static data will be access by these bellow methods

You can find here:

  1. HTTP Method
  2. HTTP Headers
  3. Request Route
  4. Query Strings
  5. Path Params
  6. Request Body

The first param in callback is reserved to request, you are free to name it as you want.

Methods

This method is responsable to return the request method

This method is responsable to return the request Headers

This method is responsable to return the request param data, path params and query strings

This method is responsable to set the query string data.

This method is responsable to get the path params

This method is responsable to return the request all data method

This method is responsable to return the request Body

Run


CORS

To configurate your CORS policies, you can use CORS Method.

Important: This method will make a global config CORS for all routes. If you need any more datailed configuration, you can create a Middleware and change an specific headers.

EXEMPLES:

Exemple to use this package

Middleware Delcaration


MiddlewaresMap.php

This file will fill Midleware Queue with middleware namespace and names.


Routes.php

This will be the file when we will make routes declarate. It can be with more than one file too..

To load all your routes to system you can use the

It will load all files from an path. Use it it before run app.


index.php


All versions of http with dependencies

PHP Build Version
Package Version
Requires patrick-barreto/exception Version ^1.0
php Version >=7.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 patrick-barreto/http contains the following files

Loading the files please wait ....