Download the PHP package webberwu/restful-php without Composer
On this page you can find all versions of the php package webberwu/restful-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download webberwu/restful-php
More information about webberwu/restful-php
Files in webberwu/restful-php
Package restful-php
Short Description This package is forked from rainner/restful-php which parses the raw input body for all RESTful verbs (POST, PUT, DELETE, PATCH, etc.) and provides a better way for working with uploaded files.
License MIT
Informations about the package restful-php
PHP Restful Package
This package is forked from rainner/restful-php.
This is a small package for working with HTTP input data in PHP. When a POST request comes into PHP, the Content-Type and Content-Body (Raw input) of the request are handled and parsed into the _POST/_FILES arrays. This package parses the raw input body for all RESTful verbs (POST, PUT, DELETE, PATCH, etc.) into the _REQUEST/_FILES arrays and provides a better way for working with uploaded files.
HTTP Input Parser Usage
The Parser class will do the same thing PHP already does for GET/POST data, but for all other REQUEST_METHOD verbs and put the data into the $_REQUEST and $_FILES super globals (Without $_COOKIE).
This class looks at the Content-Type of the request to decide how it will parse the raw content body of the request. As long as the request is formatted properly it should work without any issues. Currently it is capable of parsing the following content types:
text/plain
as INI data.text/html
as HTML formatted data.application/json
as JSON encoded data.application/x-www-form-urlencoded
as URL encoded data.application/xml
as XML formatted data.multipart/form-data
as Multipart form data.
Multi-dimentional array type property names (multi[level][name]
) are also supported and parsed into regular array by this class.
Restful\Parser public methods:
Name | Args | Return | Description |
---|---|---|---|
resolveMethod() |
none |
null |
Resolve request method verb |
resolveInput() |
none |
null |
Resolve content-type and other input data |
setContentType() |
$ctype |
null |
Set the content-type to use |
setBoundary() |
$boundary |
null |
Set the form-data boundary string to use |
setRawInput() |
$input |
null |
Set the raw input string to parse |
parse() |
none |
boolean |
Parse the input data for different content types |
HTTP Files Manager
The Files class will take the $_FILES array and re-format the structure to make it much easier for working with multiple file uploads and nested multi-dimentional array keys, for example:
The form above would have two file dialogue buttons, one accepting a single file, and another accepting multiple files. Here is how we would access these files using the Files class:
Restful\Files public methods:
Name | Args | Retuen | Description |
---|---|---|---|
blacklist() |
$ext1, $ext2, ... |
null |
Set a list of file extensions to skip when moving |
parse() |
none |
null |
Parses a given FILES array |
getParsed() |
none |
null |
Returns the new parsed files array structure |
getFiles() |
$key |
array |
Returns a list of files for passed string key |
moveFiles() |
$key, $dirname, $organize |
array |
Move list of files to a folder for given key |
loopFiles() |
$key, $callback |
null |
Loops over list of files and calls a function on each |
Installation & Setup
Manual: Clone this repo somewhere in your project and use the included autoloader to load the included classes:
``
``
Composer: Run the following composer commands to include this package and install the dependency for your project:
``
Author
Rainner Lins: @raintek_
License
Licensed under MIT.