PHP code example of windwalker / io

1. Go to this page and download the library: Download windwalker/io 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/ */

    

windwalker / io example snippets

 php
use Windwalker\IO\Input;

$input = new Input;

$input->get('flower'); // Same as $_REQUEST['flower']

$input->set('flower', 'sakura');
 php
$input->get('flower', 'default');
 php
// mysite.com/?flower=<p>to be, or not to be.</p>;

$input->get('flower'); // tobeornottobe (Default cmd filter)

$input->get('flower', 'default_value', InputFilter::STRING); // to be, or not to be

$input->getString('flower'); // to be, or not to be (Same as above, using magic method)

$input->getRaw('flower') // <p>to be, or not to be.</p>
 php
// mysite.com/?flower[1]=sakura&flower[2]=olive;

$input->getArray('flower'); // Array( [1] => sakura [2] => olive)

// Get array and filter every values
$input->getArray('flower', null, '.', 'int');
 php
// mysite.com/?flower=sakura&foo=bar&king=Richard

// Get all request
$input->compact();

// To retrieve values you want
$array(
    'flower' => '',
    'king' => '',
);

$input->compact($array); // Array( [flower] => sakura [king] => Richard)

// Specify different filters for each of the inputs:
$array(
    'flower' => InputFilter::CMD,
    'king' => InputFilter::STRING,
);

// Use nested array to get more complicated hierarchies of values

$input->compact(array(
    'windwalker' => array(
        'title' => InputFilter::STRING,
        'quantity' => InputFilter::INTEGER,
        'state' => 'integer' // Same as above
    )
));
 php
$value = $input->get('foo.bar.baz', 'default', InputFilter::STRING);

$input->set('foo.bar.baz', $data);

// Use custom separator
$input->get('foo/bar/baz', 'default', [filter], '/');
$input->set('foo/bar/baz', $data, '/');
 php
$post = $input->post;

$value = $post->get('foo', 'bar');

// Other inputs
$get    = $input->get;
$put    = $input->put;
$delete = $input->delete;
 php
$env     = $input->env;
$session = $input->session;
$cookie  = $input->cookie;
$server  = $input->server;

$server->get('REMOTE_ADDR'); // Same as $_SERVER['REMOTE_ADDR'];
 php
$method = $input->getMethod();
 php
$files = $input->files->get('flower');