caridea / dao
A shrimp of a DAO support library
Requires
- php: >=7.1.0
- caridea/event: ^3.0
- psr/log: ^1.0
Requires (Dev)
- doctrine/orm: ^2.0.0
- mongodb/mongodb: ^1.2.0
- phpunit/phpunit: ^6.0.0
Suggests
- ext-mongodb: Allows use of MongoDB DAO
- doctrine/orm: Allows use of Doctrine2 DAO
- mongodb/mongodb: In case you want to make life easier for yourself
This package is not auto-updated.
Last update: 2024-11-09 19:56:34 UTC
README
Caridea is a miniscule PHP application library. This shrimpy fellow is what you'd use when you just want some helping hands and not a full-blown framework.
This is its Data Access Object support component. You can use these classes to support DAOs that you write.
Installation
You can install this library using Composer:
$ composer require caridea/dao
- The master branch (version 3.x) of this project requires PHP 7.1 and depends on
caridea/event
. - Version 2.x of this project requires PHP 7.0 and depends on
caridea/event
.
Compliance
Releases of this library will conform to Semantic Versioning.
Our code is intended to comply with PSR-1, PSR-2, and PSR-4. If you find any issues related to standards compliance, please send a pull request!
Documentation
- Head over to Read the Docs
Features
We provide a mechanism to translate vendor-specific exceptions (right now, MongoDB and Doctrine exceptions) into a standard exception hierarchy.
Conflicting
– An exception for concurrency failures.Inoperable
– An exception for invalid API usage and configuration problems.Locked
– An exception for unwritable records.Unreachable
– An exception for connection problems.Unretrievable
– An exception for unexpected results, for instance no results or too many results.Violating
– An exception for constraint violations.Duplicative
– An exception for unique constraint violations.
- When all else fails, there's
Generic
.
We also provide abstract DAOs that allow you to make calls against your persistence API and have exceptions translated automatically.
class MyDao extends \Caridea\Dao\MongoDb { public function create($record) { $this->logger->info("Creating the record"); $this->doExecute(function ($manager, $collection) use ($record) { $bulk = new \MongoDB\Driver\BulkWrite(); $bulk->insert($record); return $manager->executeBulkWrite($collection, $bulk); }); } }