b2pweb / bdf-prime
Bdf Prime ORM
Installs: 8 102
Dependents: 9
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 0
Open Issues: 11
Requires
- php: ~7.4 | ~8.0
- ext-mbstring: *
- b2pweb/bdf-dsn: ~1.0
- b2pweb/bdf-event-notifier: ~1.0
- b2pweb/bdf-serializer: ~1.0
- b2pweb/bdf-util: ~1.0
- benmorel/weakmap-polyfill: ^0.3.0
- doctrine/dbal: ~3.0
- doctrine/inflector: ~1.0
- doctrine/instantiator: ^1.0.3|~2.0
- nette/php-generator: ~3.6|~4.0
- psr/container: ~1.0|~2.0
- psr/log: ~1.0|~2.0|~3.0
- psr/simple-cache: ^1.0
- ramsey/uuid: ^4.2
- symfony/filesystem: ~4.3|~5.0|~6.0|~7.0
- symfony/polyfill-php80: ~1.16
Requires (Dev)
- b2pweb/bdf-phpunit: ~1.0
- cache/array-adapter: ~1.0
- friendsofphp/php-cs-fixer: ~3.64
- nikic/php-parser: ^4.15
- phpbench/phpbench: ^1.2
- phpunit/phpunit: ~9.0
- symfony/console: ~4.3|~5.0|~6.0|~7.0
- symfony/http-foundation: ~4.3|~5.0|~6.0|~7.0
- symfony/http-kernel: ~4.3|~5.0|~6.0|~7.0
- symfony/phpunit-bridge: ~4.3|~5.0|~6.0|~7.0
- symfony/validator: ~4.3|~5.0|~6.0|~7.0
- vimeo/psalm: ~5.26
Suggests
- b2p/bdf-console: required to use prime commands (~1.5)
- b2p/bdf-web: required to use service provider (~1.5)
- nikic/php-parser: required to use closure filters (~4.15)
Conflicts
- doctrine/cache: >=2.0
- 2.2.x-dev
- 2.1.x-dev
- v2.1.2
- v2.1.1
- v2.1.0
- 2.0.x-dev
- v2.0.8
- v2.0.7
- v2.0.6
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- 1.3.x-dev
- v1.3.1
- v1.3.0
- v1.2.2
- v1.2.1
- v1.2.0
- v1.1.0
- 1.0.x-dev
- v1.0.2
- v1.0.1
- v1.0.0
- dev-feature-FRAM-179-event-objects
- dev-feature-FRAM-178-php84-features
- dev-fix-FRAM-169-constraint-removed-on-query-reuse
- dev-fix-FRAM-170-walker-ignore-key-not-selected
- dev-feature-FRAM-165-psr-20-clock
- dev-feature-FRAM-158-compile-query
- dev-feature-FRAM-151-value-object
- dev-feature-FRAM-149-explain-middleware
This package is auto-updated.
Last update: 2024-11-20 15:43:15 UTC
README
Prime is a Data mapper ORM based on doctrine DBAL. The goal of prime is to lightweight usage of data mapper and doctrine DBAL.
Getting Started
See Wiki for more information
composer require b2pweb/bdf-prime
<?php use Bdf\Prime\ConnectionManager; use Bdf\Prime\Entity\Model; use Bdf\Prime\Mapper\Mapper; use Bdf\Prime\Mapper\Builder\FieldBuilder; use Bdf\Prime\Mapper\Builder\IndexBuilder; use Bdf\Prime\Query\Expression\Like; use Bdf\Prime\ServiceLocator; // Declare your entity class User extends Model { public $id; public $firstName; public $lastName; public $email; public function __construct(array $data) { $this->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();