Skip to content

Commit 985eeef

Browse files
docs: fix namespace, package name, CLI commands, fabricated constructors
The whole docs tree used PivotPHP\Core\CycleORM\* (real namespace is PivotPHP\CycleORM\*, no Core segment) and told users to install pivotphp/core-cycle-orm-extension (doesn't exist on Packagist; real package is pivotphp/cycle-orm). Fixed both across 11 files. CLI docs described a vendor/bin/pivotphp binary and a bin/console that this package never shipped — SchemaCommand/MigrateCommand/EntityCommand/ StatusCommand are plain PHP classes with handle(): int, not wired to any executable. Documented the real invocation pattern everywhere, including removing a fabricated cycle:migrate:create subcommand that doesn't exist. Fixed fabricated constructor calls that would fatal if copied (CycleServiceProvider/TransactionMiddleware missing required Application $app arg), an invented Laravel-style rules API on EntityValidationMiddleware (real API is reflection-based validateEntity()), and CycleRequest::paginate()'s wrong signature. Corrected version/PHPStan-level badges after verifying against the real test run (67/67 passing) and phpstan.neon + composer script. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 0ee8453 commit 985eeef

20 files changed

Lines changed: 140 additions & 112 deletions

CHANGELOG.md

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ This release focuses on performance optimizations, cross-platform compatibility,
5757
- **Compatibility**: Maintains full backward compatibility with existing APIs
5858
- **Dependencies**: Updated to PivotPHP Core v1.1.0 from Packagist
5959
- **Testing**: 67 tests passing with 242 assertions
60-
- **Static Analysis**: PHPStan Level 8 compliance maintained
60+
- **Static Analysis**: PHPStan Level 9 compliance maintained
6161
- **Code Style**: 100% PSR-12 compliant
6262

6363
#### 🎯 **Benefits**
@@ -116,25 +116,22 @@ First stable release of PivotPHP Cycle ORM integration, providing robust databas
116116
- Best practices and examples
117117

118118
#### CLI Commands
119-
```bash
120-
php vendor/bin/pivotphp cycle:entity User # Create entity
121-
php vendor/bin/pivotphp cycle:migrate # Run migrations
122-
php vendor/bin/pivotphp cycle:schema # Update schema
123-
php vendor/bin/pivotphp cycle:status # Check status
124-
```
119+
`Commands\EntityCommand`, `MigrateCommand`, `SchemaCommand`, `StatusCommand` — plain
120+
PHP classes (`handle(): int`), not a bundled binary. See README.md's "Custom Commands"
121+
section for the real invocation pattern (no `vendor/bin/pivotphp` is shipped).
125122

126123
#### Basic Usage
127124
```php
128125
use PivotPHP\Core\Core\Application;
129126
use PivotPHP\CycleORM\CycleServiceProvider;
130127

131128
$app = new Application();
132-
$app->register(new CycleServiceProvider());
129+
$app->register(new CycleServiceProvider($app));
133130

134131
// Use in routes
135-
$app->get('/users', function (CycleRequest $request) {
136-
$users = $request->getRepository(User::class)->findAll();
137-
return $request->response()->json($users);
132+
$app->get('/users', function (CycleRequest $request, $res) {
133+
$users = $request->repository(User::class)->findAll();
134+
return $res->json($users);
138135
});
139136
```
140137

@@ -167,7 +164,7 @@ For questions, issues, or contributions:
167164

168165
---
169166

170-
**Current Version**: v1.0.0
171-
**Release Date**: July 7, 2025
172-
**Stability**: Stable
173-
**Framework Requirement**: PivotPHP Core v1.0.0+
167+
**Current Version**: v1.0.1
168+
**Release Date**: July 9, 2025
169+
**Stability**: Stable
170+
**Framework Requirement**: PivotPHP Core ^1.1.0 (see composer.json)

README.md

Lines changed: 46 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
[![PHP Version](https://img.shields.io/badge/php-%3E%3D8.1-blue.svg)](https://www.php.net/)
66
[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
7-
[![Latest Stable Version](https://img.shields.io/badge/version-1.0.0-brightgreen.svg)](https://github.com/PivotPHP/pivotphp-cycle-orm/releases)
7+
[![Latest Stable Version](https://img.shields.io/badge/version-1.0.1-brightgreen.svg)](https://github.com/PivotPHP/pivotphp-cycle-orm/releases)
88
[![PHPStan](https://img.shields.io/badge/PHPStan-Level%209-success.svg)](https://phpstan.org/)
99
[![Tests](https://img.shields.io/badge/tests-67%20passed-success.svg)](https://github.com/PivotPHP/pivotphp-cycle-orm/actions)
1010

@@ -44,20 +44,21 @@ cd pivotphp-cycle-orm
4444
composer install
4545
```
4646

47-
The `composer.json` is configured to use the local path `../pivotphp-core` for development.
48-
49-
**Note**: The CI/CD pipeline automatically adjusts the composer configuration to use the GitHub repository instead of the local path.
47+
**Note**: `composer.json` does not currently declare a local `repositories` path
48+
to a sibling `pivotphp-core` checkout — it resolves `pivotphp/core` from Packagist
49+
like any other dependency, both locally and in CI. If you need to develop against
50+
an unreleased `pivotphp-core` change, add a local path repository yourself.
5051

5152
## 🔧 Quick Start
5253

5354
### 1. Register the Service Provider
5455

5556
```php
5657
use PivotPHP\Core\Core\Application;
57-
use PivotPHP\Core\CycleORM\CycleServiceProvider;
58+
use PivotPHP\CycleORM\CycleServiceProvider;
5859

5960
$app = new Application();
60-
$app->register(new CycleServiceProvider());
61+
$app->register(new CycleServiceProvider($app));
6162
```
6263

6364
### 2. Configure Database
@@ -150,11 +151,11 @@ class UserRepository extends Repository
150151
### Transaction Middleware
151152

152153
```php
153-
use PivotPHP\Core\CycleORM\Middleware\TransactionMiddleware;
154+
use PivotPHP\CycleORM\Middleware\TransactionMiddleware;
154155

155156
// Automatic transaction handling
156157
$app->post('/api/orders',
157-
new TransactionMiddleware(),
158+
new TransactionMiddleware($app),
158159
function (CycleRequest $request) {
159160
// All database operations are wrapped in a transaction
160161
$order = new Order();
@@ -174,7 +175,7 @@ $app->post('/api/orders',
174175
### Query Monitoring
175176

176177
```php
177-
use PivotPHP\Core\CycleORM\Monitoring\QueryLogger;
178+
use PivotPHP\CycleORM\Monitoring\QueryLogger;
178179

179180
// Enable query logging
180181
$logger = $app->get(QueryLogger::class);
@@ -192,7 +193,7 @@ $stats = $logger->getStatistics();
192193
### Health Checks
193194

194195
```php
195-
use PivotPHP\Core\CycleORM\Health\CycleHealthCheck;
196+
use PivotPHP\CycleORM\Health\CycleHealthCheck;
196197

197198
$app->get('/health', function () use ($app) {
198199
$health = $app->get(CycleHealthCheck::class);
@@ -209,22 +210,37 @@ $app->get('/health', function () use ($app) {
209210

210211
### Entity Validation Middleware
211212

213+
`EntityValidationMiddleware` takes no constructor arguments and does not support
214+
Laravel-style rule strings (`'required|string|min:3'`). It wraps the request in a
215+
`CycleRequest` and exposes `validateEntity(object $entity): array{valid: bool, errors: array<int, string>}`,
216+
a basic reflection-based check (required non-nullable properties, `string`/`int` type
217+
mismatches) that you call yourself inside your handler:
218+
212219
```php
213-
use PivotPHP\Core\CycleORM\Middleware\EntityValidationMiddleware;
220+
use PivotPHP\CycleORM\Middleware\EntityValidationMiddleware;
221+
222+
$validation = new EntityValidationMiddleware();
214223

215224
$app->post('/users',
216-
new EntityValidationMiddleware(User::class, [
217-
'name' => 'required|string|min:3',
218-
'email' => 'required|email|unique:users,email'
219-
]),
220-
$handler
225+
$validation,
226+
function (CycleRequest $request, $res) use ($validation) {
227+
$user = new User();
228+
// ...populate $user from $request...
229+
230+
$result = $validation->validateEntity($user);
231+
if (!$result['valid']) {
232+
return $res->status(422)->json(['errors' => $result['errors']]);
233+
}
234+
235+
// persist $user...
236+
}
221237
);
222238
```
223239

224240
### Performance Profiling
225241

226242
```php
227-
use PivotPHP\Core\CycleORM\Monitoring\PerformanceProfiler;
243+
use PivotPHP\CycleORM\Monitoring\PerformanceProfiler;
228244

229245
$profiler = $app->get(PerformanceProfiler::class);
230246
$profiler->startProfiling();
@@ -241,20 +257,23 @@ $profile = $profiler->stopProfiling();
241257

242258
### Custom Commands
243259

244-
```php
245-
// Create entity command
246-
php vendor/bin/pivotphp cycle:entity User
247-
248-
// Run migrations
249-
php vendor/bin/pivotphp cycle:migrate
260+
This package does **not** ship a `bin/console` executable or a `vendor/bin/pivotphp`
261+
binary. `Commands\SchemaCommand`, `MigrateCommand`, `EntityCommand`, and `StatusCommand`
262+
are plain PHP classes with a `handle(): int` method — instantiate them yourself
263+
(typically from a small console script your own project provides):
250264

251-
// Update schema
252-
php vendor/bin/pivotphp cycle:schema
265+
```php
266+
use PivotPHP\CycleORM\Commands\{SchemaCommand, MigrateCommand, EntityCommand, StatusCommand};
253267

254-
// Check database status
255-
php vendor/bin/pivotphp cycle:status
268+
(new EntityCommand(['name' => 'User'], $container))->handle(); // create entity
269+
(new MigrateCommand([], $container))->handle(); // run migrations
270+
(new SchemaCommand(['--sync' => true], $container))->handle(); // sync schema
271+
(new StatusCommand([], $container))->handle(); // check status
256272
```
257273

274+
See [Configurar Console](docs/integration-guide.md#-comandos-cli) for a complete
275+
example `bin/console` script that wires these into runnable CLI commands.
276+
258277
## 🧪 Testing
259278

260279
```bash

RELEASE_NOTES_1.0.1.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ Exit code: 0 ✅
132132

133133
### Code Quality
134134
- **100% PSR-12 compliant** with automatic fixes
135-
- **PHPStan Level 8** with zero errors
135+
- **PHPStan Level 9** with zero errors
136136
- **67 tests passing** with 242 assertions
137137
- **Clean codebase** with removed duplicates
138138

RELEASE_SUMMARY_1.0.1.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ scripts\test-coverage.ps1 # PowerShell
6161
## 🧪 Quality Metrics
6262

6363
-**67 tests passing** (100% success rate)
64-
-**PHPStan Level 8** (zero errors)
64+
-**PHPStan Level 9** (zero errors)
6565
-**PSR-12 compliant** (100% code style)
6666
-**Clean CI/CD** (exit code 0)
6767

docs/guia-completo.md

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Este guia apresenta o uso da extensão desde o básico até implementações ava
1515
### 1. Instalar via Composer
1616

1717
```bash
18-
composer require pivotphp/core-cycle-orm-extension
18+
composer require pivotphp/cycle-orm
1919
```
2020

2121
### 2. Configurar Variáveis de Ambiente
@@ -67,7 +67,7 @@ Crie o arquivo `public/index.php`:
6767
require_once __DIR__ . '/../vendor/autoload.php';
6868

6969
use PivotPHP\Core\Core\Application;
70-
use PivotPHP\Core\CycleORM\CycleServiceProvider;
70+
use PivotPHP\CycleORM\CycleServiceProvider;
7171

7272
// Criar aplicação PivotPHP
7373
$app = new Application();
@@ -1216,7 +1216,7 @@ return $container;
12161216
### 1. Middleware de Transação
12171217

12181218
```php
1219-
use PivotPHP\Core\CycleORM\Middleware\TransactionMiddleware;
1219+
use PivotPHP\CycleORM\Middleware\TransactionMiddleware;
12201220

12211221
// Aplicar em todas as rotas
12221222
$app->use(new TransactionMiddleware($app));
@@ -1230,18 +1230,15 @@ $app->post('/api/users', function ($req, $res) {
12301230

12311231
### 2. Migrations e Schema
12321232

1233-
```bash
1234-
# Sincronizar schema
1235-
php bin/console cycle:schema:sync
1236-
1237-
# Criar migration
1238-
php bin/console cycle:migrate:create create_users_table
1233+
Não há `bin/console` incluído no pacote nem um comando para gerar arquivos de migration
1234+
(`SchemaCommand`/`MigrateCommand`/`StatusCommand` não expõem isso). Invoque as classes
1235+
diretamente a partir do seu próprio script `bin/console` (veja
1236+
[integration-guide.md](integration-guide.md#-comandos-cli)):
12391237

1240-
# Executar migrations
1241-
php bin/console cycle:migrate
1242-
1243-
# Verificar status
1244-
php bin/console cycle:status
1238+
```php
1239+
(new SchemaCommand(['--sync' => true], $container))->handle(); // sincronizar schema
1240+
(new MigrateCommand([], $container))->handle(); // executar migrations
1241+
(new StatusCommand([], $container))->handle(); // verificar status
12451242
```
12461243

12471244
### 3. Debugging e Profiling
@@ -1254,7 +1251,7 @@ $_ENV['CYCLE_LOG_QUERIES'] = true;
12541251
$_ENV['CYCLE_PROFILE_QUERIES'] = true;
12551252

12561253
// Coletar métricas
1257-
use PivotPHP\Core\CycleORM\Monitoring\MetricsCollector;
1254+
use PivotPHP\CycleORM\Monitoring\MetricsCollector;
12581255

12591256
$app->get('/metrics', function ($req, $res) {
12601257
$metrics = MetricsCollector::getMetrics();
@@ -1265,7 +1262,7 @@ $app->get('/metrics', function ($req, $res) {
12651262
### 4. Health Check
12661263

12671264
```php
1268-
use PivotPHP\Core\CycleORM\Health\HealthCheckMiddleware;
1265+
use PivotPHP\CycleORM\Health\HealthCheckMiddleware;
12691266

12701267
$app->get('/health', function ($req, $res) {
12711268
return $res->json(['status' => 'ok']);

docs/implementions/usage_basic.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Este guia mostra como integrar o Cycle ORM ao seu projeto PivotPHP de forma simp
66

77
1. Instale o pacote via Composer:
88
```bash
9-
composer require pivotphp/core-cycle-orm-extension
9+
composer require pivotphp/cycle-orm
1010
```
1111

1212
2. Publique as configurações (opcional):

docs/integration-guide.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Este guia detalha como integrar corretamente a PivotPHP Cycle ORM Extension em s
1616
mkdir meu-projeto && cd meu-projeto
1717

1818
# 2. Instalar dependências
19-
composer require pivotphp/core pivotphp/core-cycle-orm-extension
19+
composer require pivotphp/core pivotphp/cycle-orm
2020

2121
# 3. Criar estrutura de diretórios
2222
mkdir -p public src/{Controllers,Entities,Repositories} database app/Entities bin
@@ -32,7 +32,7 @@ mkdir -p public src/{Controllers,Entities,Repositories} database app/Entities bi
3232
declare(strict_types=1);
3333

3434
use PivotPHP\Core\Core\Application;
35-
use PivotPHP\Core\CycleORM\CycleServiceProvider;
35+
use PivotPHP\CycleORM\CycleServiceProvider;
3636
use Dotenv\Dotenv;
3737

3838
require_once dirname(__DIR__) . '/vendor/autoload.php';
@@ -139,7 +139,7 @@ CYCLE_PROFILE_QUERIES=true
139139
"require": {
140140
"php": "^8.1",
141141
"pivotphp/core": "^2.1.1",
142-
"pivotphp/core-cycle-orm-extension": "^1.0.2",
142+
"pivotphp/cycle-orm": "^1.0.2",
143143
"vlucas/phpdotenv": "^5.6"
144144
},
145145
"autoload": {
@@ -389,6 +389,11 @@ $app->run();
389389

390390
## 🔨 Comandos CLI
391391

392+
Este pacote não inclui um binário `bin/console`/`vendor/bin/pivotphp``SchemaCommand`,
393+
`MigrateCommand`, `EntityCommand` e `StatusCommand` são classes PHP simples
394+
(`handle(): int`) que você instancia a partir de um script próprio. Abaixo, um exemplo
395+
completo desse script (é código que você cria no seu projeto, não algo que o pacote fornece):
396+
392397
### Configurar Console (bin/console)
393398

394399
```php
@@ -398,10 +403,10 @@ $app->run();
398403
declare(strict_types=1);
399404

400405
use PivotPHP\Core\Core\Application;
401-
use PivotPHP\Core\CycleORM\CycleServiceProvider;
402-
use PivotPHP\Core\CycleORM\Commands\SchemaCommand;
403-
use PivotPHP\Core\CycleORM\Commands\MigrateCommand;
404-
use PivotPHP\Core\CycleORM\Commands\StatusCommand;
406+
use PivotPHP\CycleORM\CycleServiceProvider;
407+
use PivotPHP\CycleORM\Commands\SchemaCommand;
408+
use PivotPHP\CycleORM\Commands\MigrateCommand;
409+
use PivotPHP\CycleORM\Commands\StatusCommand;
405410

406411
require_once dirname(__DIR__) . '/vendor/autoload.php';
407412

@@ -563,12 +568,12 @@ $app->register(new CycleServiceProvider($app));
563568

564569
- [Documentação do PivotPHP](https://github.com/pivotphp/core)
565570
- [Documentação do Cycle ORM](https://cycle-orm.dev)
566-
- [Exemplos de código](https://github.com/pivotphp/core-cycle-orm-extension/tree/main/examples)
571+
- [Exemplos de código](https://github.com/pivotphp/cycle-orm/tree/main/examples)
567572

568573
## 🤝 Suporte
569574

570575
Se encontrar problemas:
571576

572577
1. Verifique os logs em `storage/logs/`
573578
2. Ative o debug: `APP_DEBUG=true`
574-
3. Abra uma issue no [GitHub](https://github.com/pivotphp/core-cycle-orm-extension/issues)
579+
3. Abra uma issue no [GitHub](https://github.com/pivotphp/cycle-orm/issues)

0 commit comments

Comments
 (0)