1. Go to this page and download the library: Download abmmhasan/bucket 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/ */
abmmhasan / bucket example snippets
use Infocyph\ArrayKit\Array\ArraySingle;
$list = [1, 2, 3, 2];
// Is it a list?
$isList = ArraySingle::isList($list); // true
// Duplicates
$dupes = ArraySingle::duplicates($list); // [2]
// Pagination
$page = ArraySingle::paginate($list, page:1, perPage:2); // [1, 2]
use Infocyph\ArrayKit\Array\DotNotation;
$user = [
'profile' => ['name' => 'Alice']
];
// Get value
$name = DotNotation::get($user, 'profile.name'); // Alice
// Set value
DotNotation::set($user, 'profile.email', '[email protected]');
// Flatten
$flat = DotNotation::flatten($user);
// [ 'profile.name' => 'Alice', 'profile.email' => '[email protected]' ]
use Infocyph\ArrayKit\Config\DynamicConfig;
$config = new DynamicConfig();
// Load from file
$config->loadFile(__DIR__.'/config.php');
// Hook: auto-hash password when set
$config->onSet('auth.password', fn($v) => password_hash($v, PASSWORD_BCRYPT));
// Hook: decrypt when getting 'secure.key'
$config->onGet('secure.key', fn($v) => decrypt($v));
// Use it
$config->set('auth.password', 'secret123');
$hashed = $config->get('auth.password');
use Infocyph\ArrayKit\traits\DTOTrait;
class UserDTO {
use DTOTrait;
public string $name;
public string $email;
}
$user = new UserDTO();
$user->fromArray(['name' => 'Alice', 'email' => '[email protected]']);
$array = $user->toArray();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.