Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ All notable changes to the PivotPHP Framework will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### ⚠️ Clarified Breaking Change (introduced in 2.0.0, documented here)

- `Events\EventDispatcher::dispatch()` is PSR-14 only (`dispatch(object $event): object`).
The pre-2.0 string-based dispatch (`dispatch(string $event, array $data)`) was renamed to
`fire(string $event, array $data): bool` and was never given a backward-compatible alias —
code still calling `dispatch()` with a string now gets a `TypeError`, not a deprecation
notice. `fire()`/`listen()` are a separate, lightweight event mechanism, unconnected to the
PSR-14 `dispatch()`/`ListenerProviderInterface` path and to `HookManager` (which manages its
own listeners against a `ListenerProvider` directly). If you need PSR-14 interoperable
events, use `dispatch()`/`addEventListener()`; for simple internal string-named hooks with
no cross-package interop, use `fire()`/`listen()`.

## [2.0.0] - 2025-11-15 - Modular Routing & Legacy Cleanup Edition

### 🎯 **Major Breaking Changes - Architectural Modernization**
Expand Down
162 changes: 65 additions & 97 deletions CLAUDE.md

Large diffs are not rendered by default.

74 changes: 28 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ echo "Operações: {$stats['total_operations']}\n";

### 🔍 Enhanced Error Diagnostics

PivotPHP v1.2.0 mantém **ContextualException** para diagnósticos avançados de erros:
PivotPHP v2.0.0 mantém **ContextualException** para diagnósticos avançados de erros:

#### ⚡ Sistema de Erro Inteligente

Expand Down Expand Up @@ -395,7 +395,7 @@ ContextualException::configure([
]);
```

#### ✨ Recursos v1.2.0
#### ✨ Recursos v2.0.0

- ✅ **Erro IDs Únicos** - Rastreamento facilitado para debugging
- ✅ **Sugestões Inteligentes** - Orientações específicas para resolver problemas
Expand All @@ -409,14 +409,14 @@ ContextualException::configure([
- [JsonBufferPool Optimization Guide](docs/technical/json/BUFFER_POOL_OPTIMIZATION.md)
- [Enhanced Error Diagnostics](docs/technical/error-handling/CONTEXTUAL_EXCEPTION_GUIDE.md)

### 📖 Documentação OpenAPI/Swagger Automática (v1.2.0+)
### 📖 Documentação OpenAPI/Swagger Automática (v2.0.0+)

O PivotPHP v1.2.0+ inclui **middleware automático** para geração de documentação OpenAPI/Swagger:
O PivotPHP v2.0.0+ inclui **middleware automático** para geração de documentação OpenAPI/Swagger:

```php
use PivotPHP\Core\Middleware\Http\ApiDocumentationMiddleware;

// ✅ NOVO v1.2.0+: Documentação automática em 3 linhas!
// v2.0.0: Documentação automática em 3 linhas!
$app = new Application();

// Adicionar middleware de documentação automática
Expand All @@ -426,26 +426,12 @@ $app->use(new ApiDocumentationMiddleware([
'base_url' => 'http://localhost:8080'
]));

// Suas rotas com documentação PHPDoc
// Registrar rotas normalmente
$app->get('/users', function($req, $res) {
/**
* @summary List all users
* @description Returns a list of all users in the system
* @tags Users
* @response 200 array List of users
*/
return $res->json(['users' => User::all()]);
});

$app->get('/users/:id', function($req, $res) {
/**
* @summary Get user by ID
* @description Returns a single user by their ID
* @tags Users
* @param int id User ID
* @response 200 object User object
* @response 404 object User not found
*/
$userId = $req->param('id');
return $res->json(['user' => User::find($userId)]);
});
Expand All @@ -457,14 +443,15 @@ $app->get('/users/:id', function($req, $res) {

#### 🎯 Recursos do Middleware de Documentação

- ✅ **Geração automática** de OpenAPI 3.0.0 de todas as rotas
- ✅ **Geração automática** de OpenAPI 3.0.0 de todas as rotas registradas
- ✅ **Interface Swagger UI** integrada (zero configuração)
- ✅ **Parsing de PHPDoc** para metadados das rotas
- ✅ **Endpoints automáticos** `/docs` e `/swagger`
- ✅ **Configuração flexível** de paths e URLs
- ✅ **Zero dependências** externas
- ✅ **Compatibilidade total** com todas as rotas

> **Nota**: O middleware gera paths básicos (método HTTP + caminho) a partir das rotas registradas. Metadados adicionais (descrições, tags, parâmetros) devem ser configurados manualmente no objeto OpenAPI retornado, ou via extensão futura.

#### 📝 Exemplo Completo

Veja o exemplo funcional em [`examples/api_documentation_example.php`](examples/api_documentation_example.php):
Expand Down Expand Up @@ -608,16 +595,16 @@ O PivotPHP oferece suporte duplo para PSR-7, permitindo uso com projetos moderno

### Verificar versão atual
```bash
php scripts/switch-psr7-version.php --check
php scripts/utils/switch-psr7-version.php --check
```

### Alternar entre versões
```bash
# Mudar para PSR-7 v1.x (compatível com ReactPHP)
php scripts/switch-psr7-version.php 1
php scripts/utils/switch-psr7-version.php 1

# Mudar para PSR-7 v2.x (padrão moderno)
php scripts/switch-psr7-version.php 2
php scripts/utils/switch-psr7-version.php 2
```

### Após alternar versões
Expand All @@ -633,28 +620,28 @@ Veja a [documentação completa sobre PSR-7](docs/technical/compatibility/psr7-d

---

## 🏗️ Arquitetura v1.2.0 (Simplicity Edition)
## 🏗️ Arquitetura v2.0.0 (Legacy Cleanup Edition)

O PivotPHP v1.2.0 simplifica a arquitetura seguindo o princípio "Simplicidade sobre Otimização Prematura", **priorizando facilidade de uso para provas de conceito**:
O PivotPHP v2.0.0 simplifica a arquitetura seguindo o princípio "Simplicidade sobre Otimização Prematura", **priorizando facilidade de uso para provas de conceito**:

### 🎯 Recursos v1.2.0
### 🎯 Recursos v2.0.0

#### 🚀 Array Callables Nativos
```php
// ✅ MANTIDO v1.2.0: Suporte nativo a array callables
// Suporte nativo a array callables
$app->get('/users', [UserController::class, 'index']);
$app->post('/users', [$userController, 'store']);

// Validação automática de métodos
// Validação automática de métodos
// Se método for privado/protegido, erro claro com sugestão

// Integração total com IDE
// Integração total com IDE
// Autocomplete, refactoring, jump-to-definition
```

#### 🧠 JsonBufferPool Inteligente
```php
// Sistema com threshold de 256 bytes
// Sistema com threshold de 256 bytes
// Dados pequenos: json_encode() direto (performance máxima)
// Dados grandes: pooling automático (otimização máxima)

Expand All @@ -663,7 +650,7 @@ $response = $res->json($anyData); // Sempre otimizado!

#### 🔍 Enhanced Error Diagnostics
```php
// ContextualException com sugestões inteligentes
// ContextualException com sugestões inteligentes
// Contexto rico, categorização automática, logging integrado

try {
Expand All @@ -673,10 +660,6 @@ try {
}
```

## 🏗️ Arquitetura v1.2.0 (Simplified Foundation)

O PivotPHP v1.2.0 simplifica a arquitetura v1.1.x, eliminando complexidade desnecessária:

### 🎯 Estrutura de Middlewares Organizada
```
src/Middleware/
Expand All @@ -693,25 +676,24 @@ src/Middleware/
└── ErrorMiddleware.php
```

### ✅ Melhorias da v1.2.0 (Foco em Simplicidade)
### ✅ Melhorias da v2.0.0 (Legacy Cleanup)
- **🧹 18% code reduction** - 11,871 linhas removidas, código limpo e direto
- **🎯 Orientado a Protótipos** - Arquitetura simplificada para desenvolvimento rápido
- **📚 Documentação Didática** - Exemplos práticos e guias de aprendizado
- **🔧 Setup Mínimo** - Configuração zero para começar imediatamente
- **💡 Conceitos Claros** - Estrutura lógica e intuitiva para estudos
- **🛡️ Qualidade Educacional** - PHPStan Level 9, 100% testes passando para aprendizado
- **🛡️ Qualidade** - PHPStan Level 9, PSR-12 100%, todos os testes passando

### 🔄 Migração para v1.2.0
### 🔄 Migração para v2.0.0
```php
// Imports antigos (ainda funcionam via aliases)
use PivotPHP\Core\Http\Psr15\Middleware\CorsMiddleware;
use PivotPHP\Core\Support\Arr;
// Imports v1.x (não funcionam mais — aliases removidos na v2.0.0)
use PivotPHP\Core\Http\Psr15\Middleware\CorsMiddleware; // REMOVIDO

// Imports recomendados (nova estrutura)
// Imports corretos (namespace atual)
use PivotPHP\Core\Middleware\Http\CorsMiddleware;
use PivotPHP\Core\Utils\Arr;
```

Veja o [Overview Estrutural](docs/releases/FRAMEWORK_OVERVIEW_v1.2.0.md) para detalhes completos.
Veja o [Overview Estrutural v2.0.0](docs/releases/FRAMEWORK_OVERVIEW_v2.0.0.md) para detalhes completos.

---

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"psr/log": "^3.0",
"psr/cache": "^2.0|^3.0",
"psr/simple-cache": "^2.0|^3.0",
"react/http": "^1.9",
"pivotphp/core-routing": "^1.0"
},
"require-dev": {
Expand All @@ -68,6 +67,7 @@
"ext-apcu": "For caching middleware and performance optimization",
"pivotphp/performance-tools": "Separate package with advanced pooling, caching, and middleware compilation (v2.2.0+)",
"pivotphp/cycle-orm": "Database ORM integration for PivotPHP",
"react/http": "Required for async/ReactPHP integration (pivotphp/reactphp extension)",
"pivotphp/reactphp": "Async runtime extension for continuous execution"
},
"autoload": {
Expand Down
Loading
Loading