Download the PHP package potfur/stash without Composer
On this page you can find all versions of the php package potfur/stash. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package stash
Stash - MongoDB ODM
Stash is an object-document mapper for MongoDB written in PHP. It adds a fully transparent persistence layer while still preserving MongoDB's ease of use and way of handling data.
This means that MongoDB can be used almost in the exact same way as it would be used with arrays. The small, but important, difference here is that instead of returning plain arrays, Stash will return objects (entities). And of course, Stash not only returns entities, but it also stores them.
Example
Model definitions:
Database connection:
Entity creation and storage:
And this is the stored MongoDB's semi-JSON representation.
When saving objects (entities), Stash adds the _class
field, where it stores the class name
Event subscription
Stash uses Symfonys Event Dispatcher for dispatching events.
find.after
triggered after reading document from database and converting it to entity instancepersist.before
is triggered before converting entity to array documentpersist.after
after document was saved (and updated with new_id
if needed)remove.before
triggered before entity is removed from database
Each event is represented with Event
entity, similar to Symfony's Event
but with two methods getPayload
and setPayload
to manage subject entity.
Configuring proxy
By default, all required proxy classes are generated at runtime. Generation uses a lot of reflection and it may cause poor performance. To prevent this, proxy generator needs to be configured to reuse generated proxies.
All versions of stash with dependencies
ext-mongo Version *
ocramius/proxy-manager Version 1.0.*
symfony/event-dispatcher Version ^2.7