PHPackages                             pamellayamada/pamytools - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. pamellayamada/pamytools

ActiveLibrary

pamellayamada/pamytools
=======================

Enterprise-Grade Fault-Tolerant Web Scraper, Async Transport &amp; Auto-Hydrating Engine for PHP 8.2+

v1.0.1(today)02↑2900%MITPHPPHP &gt;=8.2CI failing

Since Aug 1Pushed todayCompare

[ Source](https://github.com/PamellaYamada/Pamytools)[ Packagist](https://packagist.org/packages/pamellayamada/pamytools)[ RSS](/packages/pamellayamada-pamytools/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (1)Versions (2)Used By (0)

🚀 Pamytools Framework
=====================

[](#-pamytools-framework)

[![Latest Stable Version](https://camo.githubusercontent.com/598caa4201aadaea00ab9c93db7525eeead8852fb22673dc19b9628ba15954b5/68747470733a2f2f706f7365722e707567782e6f72672f70616d656c6c6179616d6164612f70616d79746f6f6c732f762f737461626c65)](https://packagist.org/packages/pamellayamada/pamytools)[![Total Downloads](https://camo.githubusercontent.com/bb9292ceccef5b31b28cec91d2c9dc6e110324311886d33a16ec6b3d39ceaa9b/68747470733a2f2f706f7365722e707567782e6f72672f70616d656c6c6179616d6164612f70616d79746f6f6c732f646f776e6c6f616473)](https://packagist.org/packages/pamellayamada/pamytools)[![License](https://camo.githubusercontent.com/61e122279dde7c37abd70645c20a29f175b8cb9f2af22c67223532d7043c1f3f/68747470733a2f2f706f7365722e707567782e6f72672f70616d656c6c6179616d6164612f70616d79746f6f6c732f6c6963656e7365)](https://packagist.org/packages/pamellayamada/pamytools)[![PHP Version Require](https://camo.githubusercontent.com/f06be68222c0c797c48c14ff854037f347d68b965f59a688ea0cad9cddb3a432/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f70616d656c6c6179616d6164612f70616d79746f6f6c733f636f6c6f723d383839326266)](https://packagist.org/packages/pamellayamada/pamytools)

**Pamytools** is a high-performance, fault-tolerant PHP 8.2+ framework designed for async HTTP transport, web scraping resilience via Circuit Breakers, and auto-hydration of HTML/Regex into typed DTOs using native PHP Attributes.

---

✨ Features
----------

[](#-features)

- ⚡ **Async HTTP Engine**: High-concurrency native multi-cURL transport driver.
- 🛡️ **Circuit Breaker Pattern**: Prevent cascading failures with customizable thresholds.
- 🏷️ **Native PHP Attributes**: Declarative mapping of DOMXPath and Regex into strongly-typed DTOs.
- 🌐 **Built-in I18n**: Multi-language exception and message translator out of the box (`pt-BR`, `en-US`, `es-ES`).
- 🛠️ **SOLID Architecture**: Clean, extensible interfaces designed for testability and high coverage.

---

📋 Requirements
--------------

[](#-requirements)

- **PHP**: `^8.2`
- **Extensions**: `ext-curl`, `ext-dom`, `ext-json`, `ext-libxml`

---

📦 Installation
--------------

[](#-installation)

Install the package via [Composer](https://getcomposer.org/):

```
composer require pamellayamada/pamytools
```

---

🚀 Quick Start
-------------

[](#-quick-start)

### 1. Define your DTO with Native Attributes

[](#1-define-your-dto-with-native-attributes)

Use `#[ExtractPath]` to declaratively map HTML elements or Regex patterns directly into your Data Transfer Object properties.

```
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
    ) {}
}
```

### 2. Fetch &amp; Auto-Hydrate with Resilience

[](#2-fetch--auto-hydrate-with-resilience)

Combine the async transport engine, the Circuit Breaker pattern, and the Data Hydrator into a seamless execution pipeline:

```
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']
```

---

🏗️ Project Architecture
-----------------------

[](#️-project-architecture)

```
pamytools/
├── .github/
│   └── workflows/
│       └── tests.yml
