moss / storage
moss storage
Installs: 182
Dependents: 0
Suggesters: 2
Security: 0
Stars: 2
Watchers: 2
Forks: 3
Open Issues: 1
Type:orm
Requires
- php: >=5.3.4
Requires (Dev)
- phpunit/phpunit: 3.7.*
Suggests
- psr/log: For logging queries via LoggingDecorator
This package is not auto-updated.
Last update: 2022-02-01 12:34:36 UTC
README
Storage is a simple ORM developed for MOSS framework as completely independent library. In philosophy similar to Data Mapper pattern that allows moving data from object instances to database, while keeping them independent of each other.
Active Record brakes single responsibility principle (by extending some some base class), bloats entire design... and adds unnecessary coupling. Storage approaches this differently. Entities have no direct connection to database, business logic stays uninfluenced by repositories. The only connection between entities and database is in Storage itself - in models that describe how entities relate to repositories.
Two examples (assuming that corresponding model exists):
$article = $storage->readOne('article') ->where('id', 123) ->with('comment', array(array('visible' => true))) ->execute();
This will read article entity with id=123
and with all its visible comments.
$obj = new Article('title', 'text'); $obj->comments = array( new Comment('It\'s so simple!', 'comment_author@mail'), new Comment('Yup, it is.', 'different_author@mail'), ); $storage->write($obj)->with('comment')->execute();
This would write article entity into database with set comments.
For licence details see LICENCE.md Documentation is available in ./docs/
Requirements
Just PHP >= 5.4, Doctrine DBAL and SQL database.
Installation
Download from github Or via Composer
"require": { "moss/storage": ">=0.9" }
Contribute
If you want to submit fix or some other enhancements, feel free to do so. Whenever you find a bug it would be nice if you submit it. And if you submit fix - this would be truly amazing!
How to Contribute
- Fork the Storage repository;
- Create a new branch for each feature/improvement/issue;
- Send a pull request from branch
Style Guide
All pull requests must adhere to the PSR-2 standard. All pull requests must be accompanied by passing PHPUnit tests.