Jump to content

RedBeanPHP


teppo
 Share

Recommended Posts

RedBeanPHP is a simple and easy-to-use ORM, and this module is a lightweight ProcessWire wrapper and/or loader for it.

The main task of the module is loading and setting up RedBeanPHP with database credentials from $config. There are some config settings for defining how RedBeanPHP should behave, and the module also exposes some often-used methods, but that's just about it. For more details (including a rant about why one might prefer separate ORM in some cases), take a look at the README file.

Please note that, for almost all use cases, the data modeling features of ProcessWire are much better choice than a separate database structure of your own, but in those rare cases where that's not the situation, it's good to have options. This module was a side product of one of my own projects, and I thought I might as well share it with you folks.

You can grab the module from GitHub: https://github.com/teppokoivula/RedBeanPHP.

  • Like 18
Link to comment
Share on other sites

Not many specific use cases, beyond the general examples I mentioned in the README :)

Some of my own modules have used their own database tables, partly for performance reasons, and partly because storing that kind of data on pages didn't seem like it would make sense and/or be worthwhile. Simple ORM like this can make dealing with such data easier and more enjoyable especially from developers' perspective; it's essentially a layer of abstraction, a middle ground between PDO and PW's API, and (at the very least) it can help avoid some extra rows of code.

The specific use case for which I ended up building this module for was more or less similar to those existing modules: a Process module that handles custom data. In this case I found RedBeanPHP's fluid mode especially cool, as I could just dispense beans, add content, store the beans, and RB would create a schema for me automatically. RAD at it's finest, and at the end I could just switch to frozen mode, add some indexes, and be done with it :)

Other than that, I would imagine that this could come in handy when dealing with content in external databases, or perhaps in SQLite databases. Haven't had many needs like that recently, but it's a topic that pops up even here sometimes.

  • Like 3
Link to comment
Share on other sites

I posted on a separate thread some days ago on why this would be useful, and it seems you had the same use cases that I have a need for (or had in mind). I tried doing something similar with Propel ORM, but there is a steep overhead and I got nowhere.Thank you. I will play around with it and possibly give some feedback. :)

  • Like 3
Link to comment
Share on other sites

  • 3 years later...
  • 2 months later...

Quick update: version 2.0.0 of this module is now available via GitHub. This version includes updated RedBeanPHP library, various new config settings (including the ability to disable automatic setup of RedBeanPHP, and an option for choosing one of the trimmed down library versions with support for specific database type only), and various other updates to the module.

I've also dropped support for PW 2.x and PHP < 5.4, and updated module requirements accordingly. For pre-3.x or pre-PHP 5.4 users the legacy branch still contains old version of the module.

  • Like 5
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...