-
-
Notifications
You must be signed in to change notification settings - Fork 142
Intro
for the Eloquent ORM.
All-in-one in that it provides a good deal of extensions, that you can drop in your models selectively in order to add only chosen features that you need. Without bloating eloquent to excess.
I put all my efforts in making this package:
- easy and fun to work with
- intuitive and useful in real-world use cases
- of high quality API
I find Eloquent
to be great tool, especially when you need something done in moments. It is a pleasure to see it in action. I'd say that Taylor Otwell brought some fresh air to the vast php community with his framework, and ORM is probably the biggest part of it. He brought some rails too, of course!
This is the way I always wanted APIs to look like and the tools I created were alike. Naturally this package is the same so you can relax and have fun using it.
Let me show you example of Metable
in action (meta attributes for your model):
// hotels table: id, name, standard, timestamps - all the other are meta attributes
// let's creata a hotel in a skiing region
$hotel = new Hotel;
// simple attributes
$hotel->name = 'Schloos';
$hotel->standard = 4;
// additional attributes
$hotel->slopes_distance = 500;
$hotel->ski_region = 'Sankt Moritz';
$hotel->sauna = true;
// now just save and we're done
$hotel->save();
All of the above is pretty easy to achieve with eloquent features - no big deal.
However, you would expect (at least I would) that this will also work:
$hotel = Hotel::where('standard', '>=', 4)
->where('ski_region', 'Sankt Moritz')
->where('sauna', true)->get();
Now, this is something that is not that easy to do do. But we expect this behaviour so obviously the Metable
package does it for you - and that's what I mean by intuitive and useful - no half-measures, only complete features.
Every little bit of the package is thoroughly tested in order to make it reliable. It includes unit-tests and functional/integration tests with the help of PHPUnit and Mockery and most of the stuff was born in TDD process.
As you probably noticed there are coverage
and scrutinizer
badges on the homepage of the repo - that's not just kind of show off. I believe both coverage and code quality tools like scrutinizer, help you notice things, that could be a problem. Either functional or design issues.
Because of the fact that active record is by definition bloated, some piece are tightly coupled to the Model
class. But wherever it is possible, things are designed to be SOLID.