Download the PHP package josantonius/request without Composer

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

PHP Request library

Latest Stable Version

Versión en español

PHP library for handling requests.



Requirements

This library is supported by PHP 7.4.

IMPORTANT: Version 2.x does not support version 1.x of this library.

IMPORTANT: Version 1.x has been considered obsolete, but if you want to use it for 5.6 versions of PHP you can have a look at its documentation.

Installation

The preferred way to install this extension is through Composer.

To install PHP Request library, simply:

composer require josantonius/request

The previous command will only install the necessary files, if you prefer to download the entire source code you can use:

composer require josantonius/request --prefer-source

You can also clone the complete repository with Git:

$ git clone https://github.com/Josantonius/php-request.git

Or install it manually:

Download Request.php and Validate.php:

wget https://raw.githubusercontent.com/Josantonius/php-request/master/src/Request.php

wget https://raw.githubusercontent.com/Josantonius/php-validate/master/src/Validate.php

Available Methods

Available methods in this library:

- Check if it's a GET request

# Return (boolean)

- Check if it's a POST request

# Return (boolean)

- Check if it's a PUT request

# Return (boolean)

- Check if it's a DELETE request

# Return (boolean)

- Get request params

For PUT and DELETE requests, the content type will be checked to correctly obtain the data received in the request.

The content types compatible with this library are:

Attribute Description Type Required Default
$type Request type. string Yes

# Return anonymous function that will return the Request object when it's called

- Data sanitation and return as array

Attribute Description Type Required Default
$filters Associative array with data type for each key. Fields that are not included in the filters will not be sanitized. array No []
$default Default value. Null or the default value will be returned for fields that do not match with the data type indicated. mixed No null

# Return (array) → it will return an empty array in case of error

- Data sanitation and return as object

Attribute Description Type Required Default
$filters Associative array with data type for each key. Fields that are not included in the filters will not be sanitized. array No []
$default Default value. Null or the default value will be returned for fields that do not match with the data type indicated. mixed No null

# Return (object) → it will return an empty object in case of error

- Data sanitation and return as JSON

Attribute Description Type Required Default
$default Default value. Null or the default value will be returned for fields that do not match with the data type indicated. mixed No null

# Return (mixed|null) → value, null or customized return value

- Data sanitation and return as string

Attribute Description Type Required Default
$default Default value. Null or the default value will be returned for fields that do not match with the data type indicated. mixed No null

# Return (mixed|null) → value, null or customized return value

- Data sanitation and return as integer

Attribute Description Type Required Default
$default Default value. Null or the default value will be returned for fields that do not match with the data type indicated. mixed No null

# Return (mixed|null) → value, null or customized return value

- Data sanitation and return as float

Attribute Description Type Required Default
$default Default value. Null or the default value will be returned for fields that do not match with the data type indicated. mixed No null

# Return (mixed|null) → value, null or customized return value

- Data sanitation and return as boolean

Attribute Description Type Required Default
$default Default value. Null or the default value will be returned for fields that do not match with the data type indicated. mixed No null

# Return (mixed|null) → value, null or customized return value

- Data sanitation and return as IP address

Attribute Description Type Required Default
$default Default value. Null or the default value will be returned for fields that do not match with the data type indicated. mixed No null

# Return (mixed|null) → value, null or customized return value

- Data sanitation and return as URL

Attribute Description Type Required Default
$default Default value. Null or the default value will be returned for fields that do not match with the data type indicated. mixed No null

# Return (mixed|null) → value, null or customized return value

- Data sanitation and return as email

Attribute Description Type Required Default
$default Default value. Null or the default value will be returned for fields that do not match with the data type indicated. mixed No null

# Return (mixed|null) → value, null or customized return value

Quick Start

To use this library with Composer:

Or If you installed it manually, use it:

Usage

For the examples it will be simulated that the following data is received in the request:

Example data received in the request

Example of use for this library:

- Check if it's a GET request

- Check if it's a POST request

- Check if it's a PUT request

- Check if it's a DELETE request

- Access to the parameters of the request

Returns an anonymous function that will return the Request object when it's called.

- As array

- Get and sanitize all data and return them as array

- Obtain, sanitize all data and return them as array and filter each value according to the data type

- Obtain, sanitize all data and return them as array, filter each value according to the data type and specify a value for each key when it's wrong

- As object

- Get and sanitize all data and return them as object

- Obtain, sanitize all data and return them as object and filter each value according to the data type

- Obtain, sanitize all data and return them as object, filter each value according to the data type and specify a value for each key when it's wrong

- As JSON

- Get and sanitize all data and return them as JSON

- Get specific key value, sanitize data and return them as JSON

- As string

- Get specific key value, sanitize data and return them as string

- As integer

- Get specific key value, sanitize data and return them as integer

- As float

- Get specific key value, sanitize data and return them as float

- As boolean

- Get specific key value, sanitize data and return them as boolean

- As IP

- Get specific key value, sanitize data and return them as IP

- As URL

filterRequest

- Get specific key value, sanitize data and return them as URL

- As email

- Get specific key value, sanitize data and return them as email

Tests

To run composer and to execute the following:

git clone https://github.com/Josantonius/php-request.git

cd php-request

composer install

Run unit tests with PHPUnit:

gnome-terminal -e 'php -S localhost:8000 -t tests/'

composer phpunit

Run PSR2 code standard tests with PHPCS:

composer phpcs

Run PHP Mess Detector tests to detect inconsistencies in code style:

composer phpmd

Run all previous tests:

composer tests

Sponsor

If this project helps you to reduce your development time, you can sponsor me to support my open source work :blush:

License

This repository is licensed under the MIT License.

Copyright © 2017-2022, Josantonius


All versions of request with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4
josantonius/validate 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 josantonius/request contains the following files

Loading the files please wait ....