PHP code example of stougeiro / support
1. Go to this page and download the library: Download stougeiro/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/ */
stougeiro / support example snippets
use STDW\Support\Arr;
Arr::dot(['a' => ['b' => ['c' => 1]]]);
// ['a.b.c' => 1]
Arr::undot(['a.b.c' => 1]);
// ['a' => ['b' => ['c' => 1]]]
Arr::only(['a' => 1, 'b' => 2, 'c' => 3], ['a', 'c']);
// ['a' => 1, 'c' => 3]
use STDW\Support\Base64;
$encoded = Base64::encode('hello world');
// 'aGVsbG8gd29ybGQ' (no +, /, or = characters)
Base64::decode($encoded);
// 'hello world'
use STDW\Support\Date;
Date::isValidDate('2025-03-15');
// true
Date::convert('15/03/2025', 'd/m/Y', 'Y-m-d');
// '2025-03-15'
Date::ago('2025-01-01');
// '2 months ago'
Date::fromNow('2025-06-01');
// 'in 3 months'
use STDW\Support\FileSystem;
FileSystem::unit(1048576);
// '1.00 MB'
FileSystem::size('/path/to/directory');
// 123456 (bytes)
FileSystem::rglob('/path/to/**/*.php');
// ['/path/to/src/Foo.php', '/path/to/src/Bar.php']
use STDW\Support\Password;
$hash = Password::hash('secret');
Password::verify('secret', $hash);
// true
Password::strength('MyP@ssw0rd!');
// 4
Password::validate('weak', ['min' => 8]);
// false
use STDW\Support\Str;
Str::slugify('São Paulo: A Capital!');
// 'sao-paulo-a-capital'
Str::mask('(##) #####-####', '11999991234');
// '(11) 99999-1234'
Str::onlyNumbers('(11) 99999-1234');
// '11999991234'
Str::isFqcn('App\Models\User');
// true
use STDW\Support\TTL;
TTL::minutes(30);
// 1800
TTL::days(7);
// 604800
TTL::forever();
// PHP_INT_MAX