1. Go to this page and download the library: Download schnittstabil/get 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/ */
schnittstabil / get example snippets
use Schnittstabil\Get;
echo 'Hello '.Get\value('name', $_REQUEST, 'John Doe');
echo 'Hello '.Get\valueOrFail('PHP_AUTH_USER', $_SERVER, 'User is not authenticated.');
echo 'user: '.Get\env('DB_USER', 'root');
echo 'password: '.Get\envOrFail('DB_PASS', 'DB_PASS is not set');
/**
* Return array values and object properties.
*
* @param string|int|mixed[] $path the path
* @param object|array|null $target the target
* @param mixed $default default value if $path is not valid
*
* @return mixed the value determined by `$path` or otherwise `$default`
*
* @SuppressWarnings(PHPMD.StaticAccess)
*/
function value($path, $target, $default = null)
{/**/}
/**
* Return array values and object properties.
*
* @param string|int|mixed[] $path the path
* @param object|array|null $target the target
* @param mixed $message exception message
*
* @throws \OutOfBoundsException if the `$path` does not determine a member of `$target`
*
* @return mixed the value determined by `$path`
*
* @SuppressWarnings(PHPMD.StaticAccess)
*/
function valueOrFail($path, $target, $message = null)
{/**/}
use Schnittstabil\Get;
Get\valueOrFail(3, $array);
//=> throws an OutOfBoundsException
Get\valueOrFail(3, $array, 'Error Message');
//=> throws a new OutOfBoundsException('Error Message')
/**
* Converts a string value to a PHP typed value.
*
* @param mixed $value
* @return mixed
*/
function typed($value)
{/**/}
/**
* Gets the value of an environment variable.
*
* @param string $varname the variable name
* @param mixed $default default value if `$varname` is not valid
* @param mixed $typed convert environment value to a PHP typed value
* @param bool $localOnly return only values of local environment variables
*
* @return mixed the environment value determined by `$varname` or otherwise `$default`
*/
function env($varname, $default = null, $typed = true, $localOnly = false)
{/**/}
/**
* Gets the value of an environment variable.
*
* @param string $varname the variable name
* @param mixed $message exception message
* @param mixed $typed convert environment value to a PHP typed value
* @param bool $localOnly return only values of local environment variables
*
* @throws OutOfBoundsException if the `$varname` does not determine an environment value
*
* @return mixed the environment value determined by `$varname`
*/
function envOrFail($varname, $message = null, $typed = true, $localOnly = false)
{/**/}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.