varhall / dbino
Nette Database Active Record Layer
Requires
- php: >=8.1
- nette/database: ^v3.2
- nette/di: ^v3.2
- nette/security: ^v3.2
- varhall/utilino: ^v1.2
Requires (Dev)
- mockery/mockery: ^1.6
- nette/bootstrap: ^v3.2
- nette/http: ^v3.3
- nette/robot-loader: ^v4.1
- ninjify/nunjuck: ^v0.4
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Dbino is an Active Record layer for Nette Database. Every table gets a model class you query and save through, with attribute casting, events, scopes, relations and ready-made behaviours on top of Nette Database Explorer.
$author = Author::find(1); $author->name = 'Johann'; $author->save(); $books = $author->books->where('available', true)->order('title');
Features
- Models: reading and writing attributes, saving, deleting, duplicating, scopes, timestamps, soft deletes
- Queries: lazy collections with all Nette
Selectionmethods, repositories with custom query methods - Relations: one-to-many, one-to-one, belongs-to and many-to-many with attach / detach / sync
- Mutators & casting: accessors, mutators, built-in and custom casts, JSON, UUID, password hashing, serialization
- Events: model and repository lifecycle events
- Tree nodes: nested set hierarchies
- Dependency injection & testing: inject repositories into services and test them without a database
Installation
composer require varhall/dbino
Register the extension next to your database configuration:
extensions: dbino: Varhall\Dbino\DI\DbinoExtension
Then define a model:
use Varhall\Dbino\Model; class Author extends Model { protected function table() { return 'authors'; } }
See the documentation for everything else.
Versions
| State | Version | Branch | Nette Database | PHP |
|---|---|---|---|---|
| stable | ^1.0 |
v1.0 |
3.1 | 8.0+ |
| stable | ^2.0 |
v2.0 |
3.2+ | 8.1+ |
Development
The tests are written for Nette Tester and run against a real MySQL / MariaDB server. Each test creates and drops its own database, so the configured user needs the rights to do that.
composer install
DATABASE_DSN='mysql:host=127.0.0.1' DATABASE_USER=root DATABASE_PASSWORD=secret make tests
Run a single file with make tests FILE=Model/RepositoryTest.phpt, or generate a coverage report with make coverage. CI runs the suite on PHP 8.1–8.5 with MariaDB, see .github/workflows/tests.yml.
Maintainers
Thank you for using this package.