2017 © Pedro Peláez
 

framework http

Alexya's HTTP components

image

alexya-framework/http

Alexya's HTTP components

  • Tuesday, June 6, 2017
  • by manulaiko
  • Repository
  • 1 Watchers
  • 0 Stars
  • 35 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

HTTP

Alexya's HTTP components, (*1)

Contents

, (*2)

Request

The class \Alexya\Http\Request offers a wrapper for the request supergloblas ($_GET, $_POST...)., (*3)

You can retrieve the request with the method main., (*4)

The constructor accepts the following parameters:, (*5)

  • A string being the requested URI.
  • An array being GET parameters.
  • An array being POST parameters.
  • An array being COOKIE parameters.
  • An array being SERVER parameters.

Example:, (*6)

<?php

$request = new \Alexya\Http\Request(
    $_SERVER["REQUEST_URI"],
    $_GET,
    $_POST,
    $_COOKIES,
    $_FILES,
    $_SERVER
); // Which is the same as `$request = \Alexya\Http\Request::main();`

echo $request->get["param_name"];

foreach($request->headers as $key => $value) {
    echo "Requested header: {$key}: {$value}";
}

, (*7)

Response

The class \Alexya\Http\Response offers a way for create and send HTTP responses., (*8)

The constructor accepts the following parameters (all of them optional):, (*9)

  • An array being the headers.
  • A string being the response body.
  • An integer being the status code (or a string being the status name).

To send the request use the method send., (*10)

To add a new header use the method header which accepts as parameter a string being the header name and a string or an array being the value of the header., (*11)

The method status sets the status code of the response, it can be either an integer being the code or a string being the name (see Response::responseCodes)., (*12)

The method redirect sends a redirect response thrugh headers. It accepts as parameter a string being the URL to redirect, a string being the method of redirect ("Refresh" or "Location") and the status code of the redirect., (*13)

Example:, (*14)

<?php

$request = new Request();

$request->header("Content-Type", "text/html");
$request->status(200);
$request->body("

Hello World

"); Request::redirect("/Home");

The Versions

06/06 2017

dev-develop

dev-develop

Alexya's HTTP components

  Sources   Download

GNU

The Requires

  • php >=7.1

 

by Avatar manulaiko

framework php http php7 alexya

05/06 2017

dev-master

9999999-dev

Alexya's HTTP components

  Sources   Download

GNU

The Requires

  • php >=7.0

 

by Avatar manulaiko

framework php http php7 alexya

05/06 2017

3.0.2

3.0.2.0

Alexya's HTTP components

  Sources   Download

GNU

The Requires

  • php >=7.0

 

by Avatar manulaiko

framework php http php7 alexya

02/09 2016

3.0.1

3.0.1.0

Alexya's HTTP components

  Sources   Download

GNU

The Requires

  • php >=7.0

 

by Avatar manulaiko

framework php http php7 alexya

22/08 2016

3.0.0

3.0.0.0

Alexya's HTTP components

  Sources   Download

GNU

The Requires

  • php >=7.0

 

by Avatar manulaiko

framework php http php7 alexya