Download the PHP package williamheelis/restful-inputs without Composer

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

Restful Inputs for PHP

Automatically sets useful REST globals in plain PHP:

TLDR; Auto Behaviour Summary

Request When Available
$_HEADER Always — all request headers
$_JSON Only if body is JSON
$_PUT Only on PUT request
$_PATCH Only on PATCH request
$_DELETE Only on DELETE request
$_PATH After Inputs::setPath() or fallback
RESponse
$_RES Always — sent automatically at shutdown
_RES
$_RES['status_code'] number
$_RES['error'] string
$_RES['data'] any
$_RES['headers'] EG: $_RES['headers']['Content-Type'] = 'application/json';

don't mix echo

If you're using $_RES avoid using echo (even echo json_encode("me"); will make it go weird) and don't use the header command -- it can give odd results)

$_RES DEFAULTS are only ['error'] and ['data']

Out of the box this

will return this

If you want to extend (EG: to add debug) you need to tell it to by using Inputs::extend('debug');. This is by design.

EG: use this

to get

You will have to have added the line Inputs::extend('debug'); you can then use it

$_RES WARNING

If you don't call exit; and the script continues running (e.g., later logic or another $_RES['data'] overwrite), the final values of $_RES at the end of execution are what gets sent.

You control exactly when to respond by calling exit; after setting $_RES. That is the right and recommended usage pattern for this design.

Install via Composer

$_PATH

$_PATH if you've inserted and id or perhaps uid in the url you can get it but you need to provide the input mask. More complicated set ups are not supported at the moment - terminal params only on index.php

$_HEADER

Access all request headers:

$_PUT, $_PATCH, $_DELETE

These are automatically available when the request method matches: Example PUT /api/profile with body:

it is safe to test/bail on error like this if (Inputs::is('PUT')){

$_JSON

Always available if request has Content-Type: application/json.

Even for POST, PATCH, etc., $_JSON will work as long as the input is JSON.

it is safe to test if (Inputs::is('JSON')){

$_RES (Auto-Sent Response)

$_RES is automatically sent when the script finishes — no need to manually echo or http_response_code().

License

MIT


All versions of restful-inputs with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
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 williamheelis/restful-inputs contains the following files

Loading the files please wait ...