siriusphp / orm
Powerfull and fast PDO-based data mapper
2.0.0
2020-12-12 10:41 UTC
Requires
- php: >=7.2
- ext-json: *
- atlas/pdo: ^1.1
- doctrine/collections: ^1.6
- psr/event-dispatcher: 1.0
- siriusphp/sql: ^1.2
- symfony/inflector: ^4.4
Requires (Dev)
- doctrine/dbal: ^2.10
- league/event: ^3.0
- mockery/mockery: ^1.3
- nette/php-generator: ^3.4
- phpunit/phpunit: ^8.5
Suggests
- league/event: For event dispatching
This package is auto-updated.
Last update: 2024-10-14 00:26:56 UTC
README
Sirius ORM is a fast and lightweight yet flexible data mapper solution developed with DX in mind. It offers:
- Mapping rows to your own entities
- Relations and relation aggregates (COUNT/AVERAGE)
- Eager-loading & lazy-loading (without increasing the number of queries)
- Queries that let you JOIN with relations (not tables)
- Deep persistence
- Dynamically defined mappers
- Speed & low memory usage (no Entity Manager)
- 90+% code coverage
Installation
composer require siriusphp/orm
Initialization
use Sirius\Orm\Orm; use Sirius\Orm\ConnectionLocator; $connectionLocator = ConnectionLocator::new( 'mysql:host=localhost;dbname=testdb', 'username', 'password' ); $orm = new Orm($connectionLocator);
Configuration
AKA, registering mappers and relations
$orm->register('pages', MapperConfig::fromArray([ /** * here goes the configuration */ ])); // continue with the rest of mappers
Usage
// find by ID $page = $orm->find('pages', 1); // or via the mapper $page = $orm->get('pages')->find(1); // query $pages = $orm->select('pages') ->where('status', 'published') ->orderBy('date desc') ->limit(10) ->get(); // manipulate $page->title = 'Best ORM evah!'; $page->featured_image->path = 'orm_schema.png'; // persist $orm->save($page); // or via the mapper $orm->get('pages')->save($page);