1. Go to this page and download the library: Download pamellayamada/pamytools 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/ */
pamellayamada / pamytools example snippets
namespace App\DTOs;
use Pamytools\Attributes\ExtractPath;
final readonly class CompanyDTO
{
public function __construct(
#[ExtractPath(query: "//h1[@class='title']")]
public ?string $companyName,
#[ExtractPath(query: '/token=([a-z0-9]+)/', type: 'regex')]
public ?string $csrfToken
) {}
}
use App\DTOs\CompanyDTO;
use Pamytools\Http\AsyncHttpEngine;
use Pamytools\Resilience\CircuitBreaker;
use Pamytools\Parser\DataHydrator;
use Pamytools\I18n\Translator;
// 1. Set global translation locale (Default: pt-BR. Available: en-US, es-ES, pt-BR)
Translator::setLocale('en-US');
// 2. Initialize HTTP client and Circuit Breaker guard
$http = new AsyncHttpEngine();
$breaker = new CircuitBreaker(serviceName: 'ExternalAPI', failureThreshold: 3);
// 3. Execute request safely
$response = $breaker->execute(
fn() => $http->send('GET', 'https://example.com')
);
// 4. Hydrate HTML directly into DTO
$hydrator = new DataHydrator();
/** @var CompanyDTO $dto */
$dto = $hydrator->hydrate($response->body, CompanyDTO::class);
echo $dto->companyName; // Outputs extracted text from //h1[@class='title']