2025-12-09 22:00:02 +00:00
|
|
|
|
# Pairity
|
|
|
|
|
|
|
2026-01-06 16:56:40 +00:00
|
|
|
|
A partitioned‑model PHP ORM (DTO/DAO) with Query Builder, relations, raw SQL helpers, and a portable migrations + schema builder.
|
2025-12-10 13:01:07 +00:00
|
|
|
|
|
2025-12-11 13:52:08 +00:00
|
|
|
|

|
|
|
|
|
|

|
|
|
|
|
|
|
2025-12-10 13:01:07 +00:00
|
|
|
|
## Installation
|
|
|
|
|
|
|
2026-01-06 16:56:40 +00:00
|
|
|
|
- **Requirements**: PHP >= 8.2, PDO extension for your database(s)
|
|
|
|
|
|
- **Install via Composer**:
|
2025-12-10 13:01:07 +00:00
|
|
|
|
|
2026-01-06 16:56:40 +00:00
|
|
|
|
```bash
|
2025-12-10 13:01:07 +00:00
|
|
|
|
composer require getphred/pairity
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
After install, you can use the CLI at `vendor/bin/pairity`.
|
|
|
|
|
|
|
2025-12-11 17:38:20 +00:00
|
|
|
|
## Testing
|
|
|
|
|
|
|
|
|
|
|
|
This project uses PHPUnit 10. The default test suite excludes MongoDB integration tests by default for portability.
|
|
|
|
|
|
|
2026-01-06 16:56:40 +00:00
|
|
|
|
- **Install dev dependencies**:
|
|
|
|
|
|
```bash
|
2025-12-11 17:38:20 +00:00
|
|
|
|
composer install
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2026-01-06 16:56:40 +00:00
|
|
|
|
- **Run the default suite** (SQLite + unit tests; Mongo tests excluded by default):
|
|
|
|
|
|
```bash
|
2025-12-11 17:38:20 +00:00
|
|
|
|
vendor/bin/phpunit
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2026-01-06 16:56:40 +00:00
|
|
|
|
- **Run MongoDB integration tests** (requires `ext-mongodb >= 2.1` and a reachable server):
|
|
|
|
|
|
```bash
|
|
|
|
|
|
MONGO_HOST=127.0.0.1 MONGO_PORT=27017 vendor/bin/phpunit --group mongo-integration
|
2025-12-11 17:38:20 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-01-06 16:56:40 +00:00
|
|
|
|
## Quick Start
|
2025-12-11 17:38:20 +00:00
|
|
|
|
|
2026-01-06 16:56:40 +00:00
|
|
|
|
Minimal example with SQLite and a simple `users` DAO/DTO.
|
2025-12-10 13:01:07 +00:00
|
|
|
|
|
|
|
|
|
|
```php
|
|
|
|
|
|
use Pairity\Database\ConnectionManager;
|
|
|
|
|
|
use Pairity\Model\AbstractDto;
|
|
|
|
|
|
use Pairity\Model\AbstractDao;
|
|
|
|
|
|
|
|
|
|
|
|
// 1) Connect
|
|
|
|
|
|
$conn = ConnectionManager::make([
|
|
|
|
|
|
'driver' => 'sqlite',
|
|
|
|
|
|
'path' => __DIR__ . '/db.sqlite',
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
2026-01-06 16:56:40 +00:00
|
|
|
|
// 2) Define DTO + DAO
|
2025-12-10 13:01:07 +00:00
|
|
|
|
class UserDto extends AbstractDto {}
|
|
|
|
|
|
class UserDao extends AbstractDao {
|
|
|
|
|
|
public function getTable(): string { return 'users'; }
|
|
|
|
|
|
protected function dtoClass(): string { return UserDto::class; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-06 16:56:40 +00:00
|
|
|
|
// 3) CRUD
|
2025-12-10 13:01:07 +00:00
|
|
|
|
$dao = new UserDao($conn);
|
2026-01-06 16:56:40 +00:00
|
|
|
|
$created = $dao->insert(['email' => 'a@b.com', 'name' => 'Alice']);
|
|
|
|
|
|
$user = $dao->findById($created->id);
|
2025-12-11 03:09:04 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-01-06 16:56:40 +00:00
|
|
|
|
For more detailed usage and technical specifications, see [SPECS.md](SPECS.md).
|
2025-12-11 03:09:04 +00:00
|
|
|
|
|
2026-01-06 16:56:40 +00:00
|
|
|
|
## Documentation
|
|
|
|
|
|
- [Specifications](SPECS.md)
|
|
|
|
|
|
- [Milestones & Roadmap](MILESTONES.md)
|
|
|
|
|
|
- [Examples](examples/)
|
2025-12-11 03:09:04 +00:00
|
|
|
|
|
2026-01-06 16:56:40 +00:00
|
|
|
|
## Contributing
|
2025-12-11 13:37:40 +00:00
|
|
|
|
|
2026-01-06 16:56:40 +00:00
|
|
|
|
This is an early foundation. Contributions, discussions, and design proposals are welcome. Please open an issue to coordinate larger features.
|
2025-12-11 13:37:40 +00:00
|
|
|
|
|
2026-01-06 16:56:40 +00:00
|
|
|
|
## License
|
2025-12-10 13:01:07 +00:00
|
|
|
|
|
2026-01-06 16:56:40 +00:00
|
|
|
|
MIT
|