{"id":19039589,"url":"https://github.com/windwalker-io/io","last_synced_at":"2026-03-12T21:12:07.041Z","repository":{"id":20555526,"uuid":"23835438","full_name":"windwalker-io/io","owner":"windwalker-io","description":"[READ ONLY] CLI in-out and HTTP request package.","archived":false,"fork":false,"pushed_at":"2021-02-18T07:01:03.000Z","size":134,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-12-21T15:09:03.165Z","etag":null,"topics":["cli","http","input","io","psr7-request","request"],"latest_commit_sha":null,"homepage":"https://github.com/ventoviro/windwalker","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/windwalker-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-09T13:53:05.000Z","updated_at":"2024-12-16T13:49:21.000Z","dependencies_parsed_at":"2022-08-05T08:30:49.823Z","dependency_job_id":null,"html_url":"https://github.com/windwalker-io/io","commit_stats":null,"previous_names":["ventoviro/windwalker-io"],"tags_count":79,"template":false,"template_full_name":null,"purl":"pkg:github/windwalker-io/io","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windwalker-io%2Fio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windwalker-io%2Fio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windwalker-io%2Fio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windwalker-io%2Fio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/windwalker-io","download_url":"https://codeload.github.com/windwalker-io/io/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windwalker-io%2Fio/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30444406,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-12T20:23:30.529Z","status":"ssl_error","status_checked_at":"2026-03-12T20:23:14.027Z","response_time":114,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","http","input","io","psr7-request","request"],"created_at":"2024-11-08T22:17:43.924Z","updated_at":"2026-03-12T21:12:07.009Z","avatar_url":"https://github.com/windwalker-io.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Windwalker IO\n\nWindwalker IO package is an input \u0026 output handler to get request or send output to user terminal.\n\nThis package is heavily based on Joomla Input but has modified a lot, please see original concept of [Joomla Wiki](http://docs.joomla.org/Retrieving_request_data_using_JInput).   \n\n## Installation via Composer\n\nAdd this to the require block in your `composer.json`.\n\n``` json\n{\n    \"require\": {\n        \"windwalker/io\": \"~3.0\"\n    }\n}\n```\n\n## Web Input\n\nMostly, we will need to get request data from http, the `$_GET`, `$_POST` or `$_REQUEST` provides us these data.\n\nBut it is very unsafe if we only use super global variables, the Input object can help us get values from these variables and clean every string.\n  \n``` php\nuse Windwalker\\IO\\Input;\n\n$input = new Input;\n\n$input-\u003eget('flower'); // Same as $_REQUEST['flower']\n\n$input-\u003eset('flower', 'sakura');\n```\n\nThe second argument is default value if request params not exists\n\n``` php\n$input-\u003eget('flower', 'default');\n```\n\n### Filter\n\nInput use [Windwalker Filter](https://github.com/ventoviro/windwalker-filter) package to clean request string, the default filter type is `CMD`.\nWe can use other filter type:\n\n``` php\n// mysite.com/?flower=\u003cp\u003eto be, or not to be.\u003c/p\u003e;\n\n$input-\u003eget('flower'); // tobeornottobe (Default cmd filter)\n\n$input-\u003eget('flower', 'default_value', InputFilter::STRING); // to be, or not to be\n\n$input-\u003egetString('flower'); // to be, or not to be (Same as above, using magic method)\n\n$input-\u003egetRaw('flower') // \u003cp\u003eto be, or not to be.\u003c/p\u003e\n```\n\nMore filter usage please see: [Windwalker Filter](https://github.com/ventoviro/windwalker-filter)\n\n### Compact and Get Array\n\nGet data as an array.\n\n``` php\n// mysite.com/?flower[1]=sakura\u0026flower[2]=olive;\n\n$input-\u003egetArray('flower'); // Array( [1] =\u003e sakura [2] =\u003e olive)\n\n// Get array and filter every values\n$input-\u003egetArray('flower', null, '.', 'int');\n```\n\nUse `compact()` method\n\n``` php\n// mysite.com/?flower=sakura\u0026foo=bar\u0026king=Richard\n\n// Get all request\n$input-\u003ecompact();\n\n// To retrieve values you want\n$array(\n    'flower' =\u003e '',\n    'king' =\u003e '',\n);\n\n$input-\u003ecompact($array); // Array( [flower] =\u003e sakura [king] =\u003e Richard)\n\n// Specify different filters for each of the inputs:\n$array(\n    'flower' =\u003e InputFilter::CMD,\n    'king' =\u003e InputFilter::STRING,\n);\n\n// Use nested array to get more complicated hierarchies of values\n\n$input-\u003ecompact(array(\n    'windwalker' =\u003e array(\n        'title' =\u003e InputFilter::STRING,\n        'quantity' =\u003e InputFilter::INTEGER,\n        'state' =\u003e 'integer' // Same as above\n    )\n));\n```\n\n### Get And Set Multi-Level\n\nIf we want to get value of `foo[bar][baz]`, just use `get('foo.bar.baz')`:\n\n``` php\n$value = $input-\u003eget('foo.bar.baz', 'default', InputFilter::STRING);\n\n$input-\u003eset('foo.bar.baz', $data);\n\n// Use custom separator\n$input-\u003eget('foo/bar/baz', 'default', [filter], '/');\n$input-\u003eset('foo/bar/baz', $data, '/');\n```\n\n### Get Value From Other Methods\n\nWe can get other methods as a new input object.\n\n``` php\n$post = $input-\u003epost;\n\n$value = $post-\u003eget('foo', 'bar');\n\n// Other inputs\n$get    = $input-\u003eget;\n$put    = $input-\u003eput;\n$delete = $input-\u003edelete;\n```\n\n## Get SUPER GLOBALS\n\n``` php\n$env     = $input-\u003eenv;\n$session = $input-\u003esession;\n$cookie  = $input-\u003ecookie;\n$server  = $input-\u003eserver;\n\n$server-\u003eget('REMOTE_ADDR'); // Same as $_SERVER['REMOTE_ADDR'];\n```\n\nSee: [SUPER GLOBALS](http://php.net/manual/en/language.variables.superglobals.php)\n\n### Get method of current request:\n\n``` php\n$method = $input-\u003egetMethod();\n```\n\n## Json Input\n\nIf you send a request with json body or `content-type: application/json`, you can use `$input-\u003ejson` to\nget `JsonInput` and parse json values.\n\n## Files Input\n\nThe format that PHP returns file data in for arrays can at times be awkward, especially when dealing with arrays of files. \nFilesInput provides a convenient interface for making life a little easier, grouping the data by file.\n\nSuppose you have a form like:\n\n``` html\n\u003cform action=\"...\" enctype=\"multipart/form-data\" method=\"post\"\u003e\n    \u003cinput type=\"file\" name=\"flower[test][]\" /\u003e\n    \u003cinput type=\"file\" name=\"flower[test][]\" /\u003e\n    \u003cinput type=\"submit\" value=\"submit\" /\u003e\n\u003c/form\u003e\n```\n\nNormally, PHP would put these in an array called `$_FILES` that looked like:\n\n```\nArray\n(\n    [flower] =\u003e Array\n        (\n            [name] =\u003e Array\n                (\n                    [test] =\u003e Array\n                        (\n                            [0] =\u003e youtube_icon.png\n                            [1] =\u003e Younger_Son_2.jpg\n                        )\n                )\n            [type] =\u003e Array\n                (\n                    [test] =\u003e Array\n                        (\n                            [0] =\u003e image/png\n                            [1] =\u003e image/jpeg\n                        )\n                )\n            [tmp_name] =\u003e Array\n                (\n                    [test] =\u003e Array\n                        (\n                            [0] =\u003e /tmp/phpXoIpSD\n                            [1] =\u003e /tmp/phpWDE7ye\n                        )\n                )\n            [error] =\u003e Array\n                (\n                    [test] =\u003e Array\n                        (\n                            [0] =\u003e 0\n                            [1] =\u003e 0\n                        )\n                )\n            [size] =\u003e Array\n                (\n                    [test] =\u003e Array\n                        (\n                            [0] =\u003e 34409\n                            [1] =\u003e 99529\n                        )\n                )\n        )\n)\n```\n\nFilesInput produces a result that is cleaner and easier to work with:\n\n``` php\n$files = $input-\u003efiles-\u003eget('flower');\n```\n\n`$files` then becomes:\n\n```\nArray\n(\n    [test] =\u003e Array\n        (\n            [0] =\u003e Array\n                (\n                    [name] =\u003e youtube_icon.png\n                    [type] =\u003e image/png\n                    [tmp_name] =\u003e /tmp/phpXoIpSD\n                    [error] =\u003e 0\n                    [size] =\u003e 34409\n                )\n\n            [1] =\u003e Array\n                (\n                    [name] =\u003e Younger_Son_2.jpg\n                    [type] =\u003e image/jpeg\n                    [tmp_name] =\u003e /tmp/phpWDE7ye\n                    [error] =\u003e 0\n                    [size] =\u003e 99529\n                )\n\n        )\n)\n```\n\n## CLI Input \u0026 Output\n\nPlease see [Cli README](Cli)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwindwalker-io%2Fio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwindwalker-io%2Fio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwindwalker-io%2Fio/lists"}