PHP code example of koded / stdlib

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

    

koded / stdlib example snippets


$args = new \Koded\Stdlib\ExtendedArguments([
    'foo' => [
        'bar' => [
            'baz' => 42
        ]
    ]
]);

$args->get('foo.bar');
// returns ['baz' => 42]

$args->get('foo.bar.baz');
// returns 42

$args->flatten();
// returns ['foo.bar.baz' => 42]

$args->set('foo.bar', 'baz');
// ['foo' => ['bar' => 'baz']]

$app->config()->fromPhpFile('myconfig.php');
$app->config()->fromJsonFile('myconfig.json');
$app->config()->fromEnvFile('.env');
$app->config()->fromIniFile('myconfig.ini');

$app->config()->fromObject(MyConfig::class);
$app->config()->fromObject($myconfig); // $myconfig is instance of Config

$app->config()->fromEnvVariable('MY_APP_SETTINGS');

putenv('MY_APP_SETTINGS=/path/to/config/file.php');

function arguments(...$values): Argument;
function extended(...$values): ExtendedArguments;
function value(...$values): Data;
function tap(mixed $value, callable $callable = null): mixed;
function camel_to_snake_case(string $string): string;
function env(string $name = null, mixed $default = null, array $initialState = null): mixed;
function error_log(string $function, string $message, $data): void;
function htmlencode(string $input, string $encoding = 'UTF-8'): string;
function is_associative(array $array): bool;
function json_serialize($value, int $options = JSON_PRESERVE_ZERO_FRACTION | JSON_UNESCAPED_SLASHES): string;
function json_unserialize(string $json, bool $associative = false);
function now(): DateTimeImmutable;
function randomstring(int $length = 16, string $prefix = '', string $suffix = ''): string;
function rmdir(string $dirname): bool;
function snake_to_camel_case(string $string): string;
function to_delimited_string(string $string, int $delimiter): string;
function to_kebab_string(string $string): string;
function xml_serialize(string $root, iterable $data): string;
function xml_unserialize(string $xml): array;
shell script
export MY_APP_SETTINGS='/path/to/config/file.php'