PHPackages                             tbolner/flex-php-io - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. tbolner/flex-php-io

ActiveLibrary[CLI &amp; Console](/categories/cli)

tbolner/flex-php-io
===================

IO library for web and CLI applications.

1.0.0(7y ago)18.2k—0%Apache-2.0PHPPHP &gt;=7.1

Since Jan 29Pushed 6y ago1 watchersCompare

[ Source](https://github.com/bolner/FlexPhpIO)[ Packagist](https://packagist.org/packages/tbolner/flex-php-io)[ RSS](/packages/tbolner-flex-php-io/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

FlexPhpIO
=========

[](#flexphpio)

An example of an I/O library. This project shows an alternative to handling output through the router framework. Most router frameworks expect the output to be passed back in the controllers in a "return" statement. Then for example they would convert the array to JSON.

In my opinion that solution becomes too problematic, when changes and new output modes are introduced later on to the project. Routing and IO are better be separated into 2 distinct libraries.

Functions:

- Help handling output buffering
- Handy methods to change content type
- Access HTTP/GET parameters in a type-safe manner.
- Help with the JSON format (input / output)

RequestResponseRequest::getPostedJson(): arrayResponse::printJson(array $json, $http\_status\_code = 200)Request::getIntParameter(string $paramName): intResponse::bufferStart()Request::getFloatParameter(string $paramName): floatResponse::bufferEndClean()Request::getStringParameter(string $paramName): stringResponse::isBufferEnabled(): boolRequest::getBoolParameter(string $paramName): boolResponse::JsonContentType($http\_status\_code = 200)Request::isParameterSet(string $paramName): boolResponse::HtmlContentType($http\_status\_code = 200)Request::getHttpRequestMethod(): stringResponse::TextContentType($http\_status\_code = 200)For everything else, use the built-in functions of PHP.

Recommended IDE: [PhpStorm](https://www.jetbrains.com/phpstorm/)

Packagist page:

Example usages
--------------

[](#example-usages)

```
