https://github.com/libreworks/caridea-dao
:fried_shrimp: Caridea is a miniscule PHP application library. This is a shrimpy DAO support library.
https://github.com/libreworks/caridea-dao
Last synced: 11 months ago
JSON representation
:fried_shrimp: Caridea is a miniscule PHP application library. This is a shrimpy DAO support library.
- Host: GitHub
- URL: https://github.com/libreworks/caridea-dao
- Owner: libreworks
- License: apache-2.0
- Created: 2016-08-19T14:30:05.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2018-01-29T00:11:48.000Z (over 8 years ago)
- Last Synced: 2025-05-12T21:05:49.514Z (about 1 year ago)
- Language: PHP
- Homepage:
- Size: 35.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# caridea-dao
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.
[](https://packagist.org/packages/caridea/dao)
[](https://travis-ci.org/libreworks/caridea-dao)
[](https://scrutinizer-ci.com/g/libreworks/caridea-dao/?branch=master)
[](https://scrutinizer-ci.com/g/libreworks/caridea-dao/?branch=master)
[](http://caridea-dao.readthedocs.io/en/latest/?badge=latest)
## Installation
You can install this library using Composer:
```console
$ 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](http://semver.org).
Our code is intended to comply with [PSR-1](http://www.php-fig.org/psr/psr-1/), [PSR-2](http://www.php-fig.org/psr/psr-2/), and [PSR-4](http://www.php-fig.org/psr/psr-4/). If you find any issues related to standards compliance, please send a pull request!
## Documentation
* Head over to [Read the Docs](http://caridea-dao.readthedocs.io/en/latest/)
## 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.
```php
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);
});
}
}
```