https://github.com/b2pweb/bdf-prime
Prime ORM for php
https://github.com/b2pweb/bdf-prime
Last synced: 10 months ago
JSON representation
Prime ORM for php
- Host: GitHub
- URL: https://github.com/b2pweb/bdf-prime
- Owner: b2pweb
- License: mit
- Created: 2020-05-21T16:20:24.000Z (about 6 years ago)
- Default Branch: 2.3
- Last Pushed: 2025-05-09T14:36:53.000Z (about 1 year ago)
- Last Synced: 2025-07-04T19:53:02.645Z (12 months ago)
- Language: PHP
- Size: 1.82 MB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG
- License: LICENSE
Awesome Lists containing this project
README
## Prime
Prime is a Data mapper ORM based on doctrine DBAL.
The goal of prime is to lightweight usage of data mapper and doctrine DBAL.
[](https://github.com/b2pweb/bdf-prime/actions/workflows/php.yml)
[](https://scrutinizer-ci.com/g/b2pweb/bdf-prime/?branch=2.0)
[](https://codecov.io/github/b2pweb/bdf-prime)
[](https://packagist.org/packages/b2pweb/bdf-prime)
[](https://packagist.org/packages/b2pweb/bdf-prime)
[](https://shepherd.dev/github/b2pweb/bdf-prime)
### Getting Started
See [Wiki](https://github.com/b2pweb/bdf-prime/wiki) for more information
```bash
composer require b2pweb/bdf-prime
```
```PHP
import($data);
}
}
// Declare the data mapper for the entity
class UserMapper extends Mapper
{
public function schema(): array
{
return [
'connection' => 'myDB',
'table' => 'users',
];
}
public function buildFields(FieldBuilder $builder): void
{
$builder
->bigint('id')->autoincrement()
->string('firstName')
->string('lastName')
->string('email')
;
}
public function buildIndexes(IndexBuilder $builder): void
{
$builder->add()->on('name');
}
}
// Declare your connections
$connexions = new ConnectionManager();
$connexions->declareConnection('myDB', 'mysql://myuser:mypassword@localhost');
// Use the service locator to locate your repositories
$manager = new ServiceLocator($connexions);
Locatorizable::configure($manager);
$repository = $manager->repository(User::class);
// Get and update an entity
$user = User::findById(1);
$user->setFirstName('john')->save();
// Use a query builder for searching entities
User::where('firstName', 'john')->orWhere('email', (new Like('john%'))->startsWith())->all();
```