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
4444composer 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
5657use 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
0 commit comments