jeyroik / i-have-repository
There is no license information available for the latest version (0.2.0) of this package.
Simple repository wrapper
0.2.0
2025-09-11 08:10 UTC
Requires
- jeyroik/i-have-attributes: 1.*
- jeyroik/i-have-date: 0.*
- jeyroik/i-have-id: 0.*
- ramsey/uuid: 4.*
Requires (Dev)
- phpstan/phpstan: 0.*
- phpunit/phpunit: ^12
This package is auto-updated.
Last update: 2025-09-11 08:12:56 UTC
README
Framework agnostic repository base
usage
example
use jeyroik\interfaces\IHaveAttributes; use jeyroik\interfaces\attributes\IHaveIdString; class Some implements IHaveAttributes, IHaveIdString { use THasIdString; //... } $some = new class implements IHaveRepository { use THasRepository; public function createSome(array $data): Some { return $this->getRepo(Some::class)->insertOne($data); } }; $someItem = $some->createSome([ 'p1' => 'v1' ]); echo $someItem->p1;// v1 //if RepoPluginUUid is on: echo $someItem->getId();// something like 181d7dbb-fb11-40c1-af55-ee4cefc6fa33
set envs
- DB__CLASS = class for a db driver
- DB__NAME = name for a db
- REPOSITORY__PLUGINS_FILE = path to repository plugins file
repository plugins file example
<?php use jeyroik\components\repositories\plugins\RepoPluginUuid; return [ RepoPluginUuid::class => [ //options for plugin - see in the specific plugin description ] ];