PHP code example of webberwu / restful-php

1. Go to this page and download the library: Download webberwu/restful-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

webberwu / restful-php example snippets


// parse incoming request data
$request = new Restful\Parser();
$request->parse();

// preview
echo '<pre>'.print_r( $_REQUEST, true ).'</pre>' . "\n";
echo '<pre>'.print_r( $_FILES, true ).'</pre>' . "\n";
exit;

// import and format files from the $_FILES array
$files = new Restful\Files();
$files->parse();

// work on the avatar image
$files->loopFiles( 'files.avatar', function( $file )
{
    // save to db, process, etc...
    echo $file['tmp_name'] ." <br /> \n";
});

// move photos to a folder
$photos = $files->moveFiles( 'files.photos', '/path/to/uploads' );
foreach( $photos as $photo )
{
    // check each file for upload/move errors
    echo !empty( $photo['error'] ) ? $photo['error'] : 'Success';
    echo "<br /> \n";
}

$ cd /path/to/project/libs
$ git clone https://github.com/rainner/restful-php.git



$ composer