All Projects → nilportugues → repository

nilportugues / repository

Licence: other
[PHP 7] Implementation and definition of a base Repository in Domain land.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to repository

Library
This is a project of a library, driven by real business requirements. We use techniques strongly connected with Domain Driven Design, Behavior-Driven Development, Event Storming, User Story Mapping.
Stars: ✭ 2,685 (+10226.92%)
Mutual labels:  crud, ddd, domain-driven-design, hexagonal-architecture
educational-platform
Modular Monolith Java application with DDD
Stars: ✭ 124 (+376.92%)
Mutual labels:  ddd, domain-driven-design, clean-architecture, hexagonal-architecture
Queryql
Easily add filtering, sorting, and pagination to your Node.js REST API through your old friend: the query string!
Stars: ✭ 76 (+192.31%)
Mutual labels:  pagination, filter, sort
Architecture
.NET 6, ASP.NET Core 6, Entity Framework Core 6, C# 10, Angular 13, Clean Code, SOLID, DDD.
Stars: ✭ 2,285 (+8688.46%)
Mutual labels:  ddd, domain-driven-design, clean-architecture
clean-architecture
Package for isolate your domain code from framework dependency using DDD concepts.
Stars: ✭ 93 (+257.69%)
Mutual labels:  ddd, domain-driven-design, clean-architecture
Sieve
⚗️ Clean & extensible Sorting, Filtering, and Pagination for ASP.NET Core
Stars: ✭ 560 (+2053.85%)
Mutual labels:  pagination, filter, sort
Php Ddd Example
🐘🎯 Hexagonal Architecture + DDD + CQRS in PHP using Symfony 5
Stars: ✭ 1,960 (+7438.46%)
Mutual labels:  ddd, domain-driven-design, hexagonal-architecture
Graphql To Mongodb
Allows for generic run-time generation of filter types for existing graphql types and parsing client requests to mongodb find queries
Stars: ✭ 261 (+903.85%)
Mutual labels:  pagination, filter, sort
Modular Monolith With Ddd
Full Modular Monolith application with Domain-Driven Design approach.
Stars: ✭ 6,210 (+23784.62%)
Mutual labels:  ddd, domain-driven-design, clean-architecture
sql-repository
[PHP 7] SQL Repository implementation
Stars: ✭ 37 (+42.31%)
Mutual labels:  crud, filter, pageable
eloquent-mongodb-repository
Eloquent MongoDB Repository Implementation
Stars: ✭ 18 (-30.77%)
Mutual labels:  crud, filter, pageable
Sample Dotnet Core Cqrs Api
Sample .NET Core REST API CQRS implementation with raw SQL and DDD using Clean Architecture.
Stars: ✭ 1,273 (+4796.15%)
Mutual labels:  ddd, domain-driven-design, clean-architecture
Event Sourcing Castanha
An Event Sourcing service template with DDD, TDD and SOLID. It has High Cohesion and Loose Coupling, it's a good start for your next Microservice application.
Stars: ✭ 68 (+161.54%)
Mutual labels:  ddd, domain-driven-design, clean-architecture
Gridjs
Advanced table plugin
Stars: ✭ 3,231 (+12326.92%)
Mutual labels:  pagination, filter, sort
Cp Ddd Framework
A lightweight flexible development framework for complex business architecture with full ecosystem!轻量级业务中台开发框架,中台架构的顶层设计和完整解决方案!
Stars: ✭ 566 (+2076.92%)
Mutual labels:  ddd, domain-driven-design, clean-architecture
Run Aspnetcore
A starter kit for your next ASP.NET Core web application. Boilerplate for ASP.NET Core reference application, demonstrating a layered application architecture with applying Clean Architecture and DDD best practices. Download 100+ page eBook PDF from here ->
Stars: ✭ 227 (+773.08%)
Mutual labels:  ddd, domain-driven-design, clean-architecture
express-mquery
Expose mongoose query API through HTTP request.
Stars: ✭ 37 (+42.31%)
Mutual labels:  pagination, filter, sort
typescript-ddd-course
🔷🔖 TypeScript DDD Course: Learn Domain-Driven Design in TS lesson by lesson
Stars: ✭ 28 (+7.69%)
Mutual labels:  ddd, domain-driven-design, hexagonal-architecture
Jivejdon
Jivejdon is a Domain Driven Design appication with CQRS/ES/Clean/Hexagonal architecture
Stars: ✭ 287 (+1003.85%)
Mutual labels:  ddd, domain-driven-design, clean-architecture
Dotnet New Caju
Learn Clean Architecture with .NET Core 3.0 🔥
Stars: ✭ 228 (+776.92%)
Mutual labels:  ddd, domain-driven-design, clean-architecture

Repository

PHP7 Tested Build Status Scrutinizer Code Quality SensioLabsInsight Latest Stable Version Total Downloads License Donate

Generic implementation and definition of a Repository and its in-memory implementation.

Installation

Use Composer to install the package:

$ composer require nilportugues/repository

InMemory Implementation

A custom repository can be easily created by extending the InMemoryRepository class provided.

use NilPortugues\Foundation\Infrastructure\Model\Repository\InMemory\InMemoryRepository

class MyInMemoryRepository extends InMemoryRepository
{
    //... your custom implementation.
}

Implementation can be seen here.

The base InMemoryRepository implements the following interfaces:

  • NilPortugues\Foundation\Domain\Model\Repository\Contracts\Repository
  • NilPortugues\Foundation\Domain\Model\Repository\Contracts\PageRepository
  • NilPortugues\Foundation\Domain\Model\Repository\Contracts\ReadRepository
  • NilPortugues\Foundation\Domain\Model\Repository\Contracts\WriteRepository

InMemoryRepository Example

An example with a complete implementation can be found in the /example directory.

In the example:

  • Colors are defined as a class implementing the Identity interface.
  • A ColorRepository is implemented. Will throw exception if Color is not found.
  • Examples on how to filter are provided in the example.php file.

Foundation Classes

Interaction with the repository requires the usage of the following classes or classes implementing interfaces.

  • NilPortugues\Foundation\Domain\Model\Repository\Fields

    • public function __construct(array $fields = [])
    • public function add($field)
    • public function get()
  • NilPortugues\Foundation\Domain\Model\Repository\Filter

    • public function filters()
    • public function must()
    • public function mustNot()
    • public function should()
    • public function clear()
  • NilPortugues\Foundation\Domain\Model\Repository\BaseFilter

    • public function notStartsWith($filterName, $value)
    • public function notEndsWith($filterName, $value)
    • public function notEmpty($filterName)
    • public function empty($filterName)
    • public function notNull($filterName)
    • public function empty($filterName)
    • public function startsWith($filterName, $value)
    • public function endsWith($filterName, $value)
    • public function equal($filterName, $value)
    • public function notEqual($filterName, $value)
    • public function includeGroup($filterName, array $value)
    • public function notIncludeGroup($filterName, array $value)
    • public function range($filterName, $firstValue, $secondValue)
    • public function notRange($filterName, $firstValue, $secondValue)
    • public function notContain($filterName, $value)
    • public function contain($filterName, $value)
    • public function beGreaterThanOrEqual($filterName, $value)
    • public function beGreaterThan($filterName, $value)
    • public function beLessThanOrEqual($filterName, $value)
    • public function beLessThan($filterName, $value)
    • public function clear()
    • public function get()
    • public function hasEmpty($filterName) //alias of empty() for BC reasons.
  • NilPortugues\Foundation\Domain\Model\Repository\Order

    • public function __construct($direction)
    • public function isDescending()
    • public function isAscending()
    • public function __toString()
    • public function equals($object)
    • public function direction()
  • NilPortugues\Foundation\Domain\Model\Repository\Pageable

    • public function __construct($pageNumber, $pageSize, SortInterface $sort = null, FilterInterface $filter = null, FieldsInterface $fields = null)
    • public function offset()
    • public function pageNumber()
    • public function sortings()
    • public function next()
    • public function pageSize()
    • public function previousOrFirst()
    • public function hasPrevious()
    • public function first()
    • public function filters()
    • public function fields()
  • NilPortugues\Foundation\Domain\Model\Repository\Page

    • public function __construct(array $elements, $totalElements, $pageNumber, $totalPages, SortInterface $sort = null, FilterInterface $filter = null, FieldsInterface $fields = null)
    • public function content()
    • public function hasPrevious()
    • public function isFirst()
    • public function isLast()
    • public function hasNext()
    • public function pageSize()
    • public function pageNumber()
    • public function totalPages()
    • public function nextPageable()
    • public function sortings()
    • public function filters()
    • public function fields()
    • public function previousPageable()
    • public function totalElements()
    • public function map(callable $converter)
  • NilPortugues\Foundation\Domain\Model\Repository\Sort

    • public function __construct(array $properties = [], OrderInterface $order = null)
    • public function andSort(SortInterface $sort)
    • public function orders()
    • public function equals(SortInterface $sort)
    • public function orderFor($propertyName)
    • public function setOrderFor($propertyName, OrderInterface $order)
    • public function property($propertyName)

Interfaces

  • NilPortugues\Foundation\Domain\Model\Repository\Contracts\Identity

    • public function id()
    • public function __toString()
  • NilPortugues\Foundation\Domain\Model\Repository\Contracts\Repository

    • public function count(Filter $filter = null)
    • public function exists(Identity $id)
  • NilPortugues\Foundation\Domain\Model\Repository\Contracts\PageRepository

    • public function findAll(Pageable $pageable = null)
  • NilPortugues\Foundation\Domain\Model\Repository\Contracts\ReadRepository

    • public function find(Identity $id, Fields $fields = null)
    • public function findBy(Filter $filter = null, Sort $sort = null, Fields $fields = null)
    • public function findByDistinct(Fields $distinctFields, Filter $filter = null, Sort $sort = null, Fields $fields = null)
  • NilPortugues\Foundation\Domain\Model\Repository\Contracts\WriteRepository

    • public function add($value)
    • public function addAll(array $values)
    • public function remove(Identity $id)
    • public function removeAll(Filter $filter = null)
    • public function transactional(callable $transaction)

Quality

To run the PHPUnit tests at the command line, go to the tests directory and issue phpunit.

This library attempts to comply with PSR-1, PSR-2, PSR-4.

If you notice compliance oversights, please send a patch via Pull Request.

Contribute

Contributions to the package are always welcome!

Support

Get in touch with me using one of the following means:

Authors

License

The code base is licensed under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].