1. Go to this page and download the library: Download maatify/common 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/ */
use Maatify\Common\Traits\SingletonTrait;
final class ConfigManager
{
use SingletonTrait;
public function get(string $key): ?string
{
return $_ENV[$key] ?? null;
}
}
// ✅ Always returns the same instance
$config = ConfigManager::obj();
// ♻️ Reset (for testing)
ConfigManager::reset();
use Maatify\Common\Pagination\DTO\PaginationDTO;
$pagination = new PaginationDTO(
page: 1,
perPage: 25,
total: 200,
totalPages: 8,
hasNext: true,
hasPrev: false
);
print_r($pagination->toArray());
use Maatify\Common\Helpers\TapHelper;
use Maatify\DataAdapters\Adapters\MongoAdapter;
$config = new EnvironmentConfig(__DIR__ . '/../');
$mongo = TapHelper::tap(new MongoAdapter($config), fn($a) => $a->connect());
// $mongo is now a connected adapter
$client = $mongo->getConnection();