{"id":29354237,"url":"https://github.com/pivotphp/pivotphp-cycle-orm","last_synced_at":"2026-04-08T18:03:41.285Z","repository":{"id":303298771,"uuid":"1014935711","full_name":"PivotPHP/pivotphp-cycle-orm","owner":"PivotPHP","description":"Complete Cycle ORM integration for PivotPHP - zero-config database layer with high performance and type safety for the evolutionary microframework.","archived":false,"fork":false,"pushed_at":"2025-07-07T17:20:33.000Z","size":419,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-07T17:32:24.887Z","etag":null,"topics":["cycle-orm","database","helixphp","integration","mariadb","mysql","orm","performance","php","postgresql","type-safe","zero-config"],"latest_commit_sha":null,"homepage":"https://pivotphp.github.io/website/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PivotPHP.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-06T17:40:08.000Z","updated_at":"2025-07-07T17:20:36.000Z","dependencies_parsed_at":"2025-07-06T22:05:02.513Z","dependency_job_id":"ec797a68-bf9c-4e98-ad50-8ded11ecfbff","html_url":"https://github.com/PivotPHP/pivotphp-cycle-orm","commit_stats":null,"previous_names":["helixphp/helixphp-cycle-orm","pivotphp/pivotphp-cycle-orm"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/PivotPHP/pivotphp-cycle-orm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PivotPHP%2Fpivotphp-cycle-orm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PivotPHP%2Fpivotphp-cycle-orm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PivotPHP%2Fpivotphp-cycle-orm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PivotPHP%2Fpivotphp-cycle-orm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PivotPHP","download_url":"https://codeload.github.com/PivotPHP/pivotphp-cycle-orm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PivotPHP%2Fpivotphp-cycle-orm/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264384390,"owners_count":23599612,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cycle-orm","database","helixphp","integration","mariadb","mysql","orm","performance","php","postgresql","type-safe","zero-config"],"created_at":"2025-07-09T03:11:49.684Z","updated_at":"2025-12-30T22:13:41.998Z","avatar_url":"https://github.com/PivotPHP.png","language":"PHP","readme":"# PivotPHP Cycle ORM\n\n\u003cdiv align=\"center\"\u003e\n\n[![PHP Version](https://img.shields.io/badge/php-%3E%3D8.1-blue.svg)](https://www.php.net/)\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)\n[![Latest Stable Version](https://img.shields.io/badge/version-1.0.0-brightgreen.svg)](https://github.com/PivotPHP/pivotphp-cycle-orm/releases)\n[![PHPStan](https://img.shields.io/badge/PHPStan-Level%209-success.svg)](https://phpstan.org/)\n[![Tests](https://img.shields.io/badge/tests-67%20passed-success.svg)](https://github.com/PivotPHP/pivotphp-cycle-orm/actions)\n\nRobust and well-tested Cycle ORM integration for PivotPHP microframework\n\n\u003c/div\u003e\n\n## 🚀 Features\n\n- **Seamless Integration**: Deep integration with PivotPHP Core\n- **Type Safety**: Full type safety with PHPStan Level 9\n- **Repository Pattern**: Built-in repository pattern support\n- **Performance Monitoring**: Query logging and performance profiling\n- **Middleware Support**: Transaction and validation middleware\n- **Health Checks**: Database health monitoring\n- **Zero Configuration**: Works out of the box with sensible defaults\n\n## 📦 Installation\n\n```bash\ncomposer require pivotphp/cycle-orm\n```\n\n### Development Setup\n\nWhen developing locally with both pivotphp-core and pivotphp-cycle-orm:\n\n1. Clone both repositories in the same parent directory:\n```bash\ngit clone https://github.com/PivotPHP/pivotphp-core.git\ngit clone https://github.com/PivotPHP/pivotphp-cycle-orm.git\n```\n\n2. Install dependencies:\n```bash\ncd pivotphp-cycle-orm\ncomposer install\n```\n\nThe `composer.json` is configured to use the local path `../pivotphp-core` for development.\n\n**Note**: The CI/CD pipeline automatically adjusts the composer configuration to use the GitHub repository instead of the local path.\n\n## 🔧 Quick Start\n\n### 1. Register the Service Provider\n\n```php\nuse PivotPHP\\Core\\Core\\Application;\nuse PivotPHP\\Core\\CycleORM\\CycleServiceProvider;\n\n$app = new Application();\n$app-\u003eregister(new CycleServiceProvider());\n```\n\n### 2. Configure Database\n\n```php\n// config/cycle.php\nreturn [\n    'database' =\u003e [\n        'default' =\u003e 'default',\n        'databases' =\u003e [\n            'default' =\u003e ['connection' =\u003e 'sqlite']\n        ],\n        'connections' =\u003e [\n            'sqlite' =\u003e [\n                'driver' =\u003e \\Cycle\\Database\\Driver\\SQLite\\SQLiteDriver::class,\n                'options' =\u003e [\n                    'connection' =\u003e 'sqlite:database.db',\n                ]\n            ]\n        ]\n    ]\n];\n```\n\n### 3. Define Entities\n\n```php\nuse Cycle\\Annotated\\Annotation\\Entity;\nuse Cycle\\Annotated\\Annotation\\Column;\n\n#[Entity(repository: UserRepository::class)]\nclass User\n{\n    #[Column(type: 'primary')]\n    private int $id;\n\n    #[Column(type: 'string')]\n    private string $name;\n\n    #[Column(type: 'string', unique: true)]\n    private string $email;\n\n    // Getters and setters...\n}\n```\n\n### 4. Use in Routes\n\n```php\n$app-\u003eget('/users', function (CycleRequest $request) {\n    $users = $request-\u003egetRepository(User::class)-\u003efindAll();\n\n    return $request-\u003eresponse()-\u003ejson($users);\n});\n\n$app-\u003epost('/users', function (CycleRequest $request) {\n    $user = new User();\n    $user-\u003esetName($request-\u003einput('name'));\n    $user-\u003esetEmail($request-\u003einput('email'));\n\n    $request-\u003epersist($user);\n\n    return $request-\u003eresponse()-\u003ejson($user, 201);\n});\n```\n\n## 🎯 Core Features\n\n### Repository Pattern\n\n```php\n// Custom repository\nclass UserRepository extends Repository\n{\n    public function findByEmail(string $email): ?User\n    {\n        return $this-\u003efindOne(['email' =\u003e $email]);\n    }\n\n    public function findActive(): array\n    {\n        return $this-\u003eselect()\n            -\u003ewhere('active', true)\n            -\u003eorderBy('created_at', 'DESC')\n            -\u003efetchAll();\n    }\n}\n```\n\n### Transaction Middleware\n\n```php\nuse PivotPHP\\Core\\CycleORM\\Middleware\\TransactionMiddleware;\n\n// Automatic transaction handling\n$app-\u003epost('/api/orders',\n    new TransactionMiddleware(),\n    function (CycleRequest $request) {\n        // All database operations are wrapped in a transaction\n        $order = new Order();\n        $request-\u003epersist($order);\n\n        // If an exception occurs, transaction is rolled back\n        foreach ($request-\u003einput('items') as $item) {\n            $orderItem = new OrderItem();\n            $request-\u003epersist($orderItem);\n        }\n\n        return $request-\u003eresponse()-\u003ejson($order);\n    }\n);\n```\n\n### Query Monitoring\n\n```php\nuse PivotPHP\\Core\\CycleORM\\Monitoring\\QueryLogger;\n\n// Enable query logging\n$logger = $app-\u003eget(QueryLogger::class);\n$logger-\u003eenable();\n\n// Get query statistics\n$stats = $logger-\u003egetStatistics();\n// [\n//     'total_queries' =\u003e 42,\n//     'total_time' =\u003e 0.123,\n//     'queries' =\u003e [...]\n// ]\n```\n\n### Health Checks\n\n```php\nuse PivotPHP\\Core\\CycleORM\\Health\\CycleHealthCheck;\n\n$app-\u003eget('/health', function () use ($app) {\n    $health = $app-\u003eget(CycleHealthCheck::class);\n    $status = $health-\u003echeck();\n\n    return [\n        'status' =\u003e $status-\u003eisHealthy() ? 'healthy' : 'unhealthy',\n        'database' =\u003e $status-\u003egetData()\n    ];\n});\n```\n\n## 🛠️ Advanced Usage\n\n### Entity Validation Middleware\n\n```php\nuse PivotPHP\\Core\\CycleORM\\Middleware\\EntityValidationMiddleware;\n\n$app-\u003epost('/users',\n    new EntityValidationMiddleware(User::class, [\n        'name' =\u003e 'required|string|min:3',\n        'email' =\u003e 'required|email|unique:users,email'\n    ]),\n    $handler\n);\n```\n\n### Performance Profiling\n\n```php\nuse PivotPHP\\Core\\CycleORM\\Monitoring\\PerformanceProfiler;\n\n$profiler = $app-\u003eget(PerformanceProfiler::class);\n$profiler-\u003estartProfiling();\n\n// Your database operations...\n\n$profile = $profiler-\u003estopProfiling();\n// [\n//     'duration' =\u003e 0.456,\n//     'memory_peak' =\u003e 2097152,\n//     'queries_count' =\u003e 15\n// ]\n```\n\n### Custom Commands\n\n```php\n// Create entity command\nphp vendor/bin/pivotphp cycle:entity User\n\n// Run migrations\nphp vendor/bin/pivotphp cycle:migrate\n\n// Update schema\nphp vendor/bin/pivotphp cycle:schema\n\n// Check database status\nphp vendor/bin/pivotphp cycle:status\n```\n\n## 🧪 Testing\n\n```bash\n# Run all tests\ncomposer test\n\n# Run specific test suite\ncomposer test:unit\ncomposer test:feature\ncomposer test:integration\n\n# Run with coverage (cross-platform)\ncomposer test-coverage\n\n# Platform-specific alternatives:\n# Unix/Linux/macOS\n./scripts/test-coverage.sh\n# Windows CMD\nscripts\\test-coverage.bat\n# PowerShell\nscripts\\test-coverage.ps1\n```\n\n### Cross-Platform Compatibility\n\nThe project includes cross-platform scripts for coverage testing:\n- **Primary method**: `composer test-coverage` (works on all platforms)\n- **Alternative scripts**: Platform-specific scripts in `scripts/` directory\n- **Windows support**: Both CMD and PowerShell scripts included\n\n## 📚 Documentation\n\n- [Integration Guide](docs/integration-guide.md)\n- [Complete Guide](docs/guia-completo.md)\n- [API Reference](docs/quick-reference.md)\n- [Examples](examples/)\n\n## 🤝 Contributing\n\nWe welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.\n\n## 📄 License\n\nPivotPHP Cycle ORM is open-sourced software licensed under the [MIT license](LICENSE).\n\n## 🙏 Credits\n\n- Created by [Caio Alberto Fernandes](https://github.com/CAFernandes)\n- Built on top of [Cycle ORM](https://cycle-orm.dev/)\n- Part of the [PivotPHP](https://github.com/PivotPHP) ecosystem\n\n---\n\n\u003cdiv align=\"center\"\u003e\n  \u003csub\u003eBuilt with PivotPHP - The modern PHP microframework\u003c/sub\u003e\n\u003c/div\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpivotphp%2Fpivotphp-cycle-orm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpivotphp%2Fpivotphp-cycle-orm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpivotphp%2Fpivotphp-cycle-orm/lists"}