PHP code example of iviphp / support

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

    

iviphp / support example snippets




declare(strict_types=1);

use Ivi\Support\Arr;

$config = [
    'database' => [
        'host' => '127.0.0.1',
        'port' => 3306,
    ],
];

$host = Arr::get($config, 'database.host');

Arr::set($config, 'database.charset', 'utf8mb4');

$exists = Arr::has($config, 'database.port');

Arr::forget($config, 'database.port');

Arr::get($array, $key, $default);
Arr::has($array, $key);
Arr::set($array, $key, $value);
Arr::forget($array, $key);
Arr::only($array, $keys);
Arr::except($array, $keys);



declare(strict_types=1);

use Ivi\Support\Str;

Str::studly('product_category');
Str::camel('product_category');
Str::snake('ProductCategory');
Str::kebab('ProductCategory');

Str::contains('IviPHP Framework', 'PHP');
Str::startsWith('iviphp/support', 'iviphp');
Str::endsWith('ServiceProvider.php', '.php');

Str::limit('A long description', 10);

Str::contains($value, $needle);
Str::startsWith($value, $prefix);
Str::endsWith($value, $suffix);
Str::studly($value);
Str::camel($value);
Str::snake($value);
Str::kebab($value);
Str::limit($value, $limit, $ending);



declare(strict_types=1);

use Ivi\Support\Path;

$path = Path::join(
    '/var/www',
    'storage',
    'cache'
);

$normalized = Path::normalize($path);

$isAbsolute = Path::isAbsolute($path);

$isInsideStorage = Path::isWithin(
    '/var/www/storage/cache/item.php',
    '/var/www/storage'
);

Path::join(...$segments);
Path::normalize($path);
Path::isAbsolute($path);
Path::basename($path);
Path::dirname($path);
Path::extension($path);
Path::filename($path);
Path::isWithin($path, $base);