PHPackages                             patrick-barreto/http - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. patrick-barreto/http

ActiveLibrary[HTTP &amp; Networking](/categories/http)

patrick-barreto/http
====================

This package will create the http service that will create endpoints, recive request and send response

v1.0.4(1y ago)0174GPL-3.0-or-laterPHPPHP &gt;=7.0CI passing

Since Nov 29Pushed 1y ago1 watchersCompare

[ Source](https://github.com/PatrickBarreto/Http)[ Packagist](https://packagist.org/packages/patrick-barreto/http)[ RSS](/packages/patrick-barreto-http/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (1)Versions (10)Used By (0)

About Package
=============

[](#about-package)

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

How to install
==============

[](#how-to-install)

```
composer require patrick-barreto/Http
```

How to Use
==========

[](#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.

```
use Http\Http;
```

Roates
======

[](#roates)

- POST ```
    Http::post(string $endpoint, Closure $controllerCallBack, array $middlewares = []);
    ```
- GET ```
    Http::get(string $endpoint, Closure $controllerCallBack, array $middlewares = [])
    ```
- PUT ```
    Http::put(string $endpoint, Closure $controllerCallBack, array $middlewares = [])
    ```
- PATCH ```
    Http::patch(string $endpoint, Closure $controllerCallBack, array $middlewares = [])
    ```
- DELETE ```
    Http::delete(string $endpoint, Closure $controllerCallBack, array $middlewares = [])
    ```

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

- statics routes first,
- and dinamic routes last

---

Middlewares
===========

[](#middlewares)

Create a middleware
-------------------

[](#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:

```
