# ORM and SlimFramework

**URL:** <https://discourse.slimframework.com/t/orm-and-slimframework/867>\
**Category:** Questions\
**Created:** [November 1, 2016, 5:16pm UTC](https://discourse.slimframework.com/t/orm-and-slimframework/867 "2016-11-01T17:16:52Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![AndersonDev](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/andersondev/32/50_2.png) [@AndersonDev](https://discourse.slimframework.com/u/AndersonDev)\
**Post date:** [November 1, 2016, 5:16pm UTC](https://discourse.slimframework.com/t/orm-and-slimframework/867/1 "2016-11-01T17:16:52Z")

</div>

Hi. I have a project api on Slim. I am using SQL to save/fetch/delete/update date in MySql database. However it takes time an much space in bigger project to use and manage this.

Now I am thinking to move to some ORM like Eloquent.

- Is this better than SQL?
- Which ORM is the best and comfortable?

Thanks!

---

<div class="post-metadata">

**Author:** ![tflight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/tflight/32/1205_2.png) [@tflight](https://discourse.slimframework.com/u/tflight)\
**Post date:** [November 1, 2016, 5:25pm UTC](https://discourse.slimframework.com/t/orm-and-slimframework/867/2 "2016-11-01T17:25:03Z")

</div>

Those questions are likely to yield many different opinions. I’d say if you can ultimately develop projects faster with fewer bugs, then it is worth it. The trade-offs might include speed, memory, and testability.

Likewise there are many different opinions about the “best” ORM. After checking out a few including Eloquent, Fuel, RedBean, and Propel, I ended up using Eloquent as it was the most intuitive to me and it had the most tutorials.

---

<div class="post-metadata">

**Author:** ![AndersonDev](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/andersondev/32/50_2.png) [@AndersonDev](https://discourse.slimframework.com/u/AndersonDev)\
**Post date:** [November 1, 2016, 5:50pm UTC](https://discourse.slimframework.com/t/orm-and-slimframework/867/4 "2016-11-01T17:50:45Z")

</div>

Yes Eloquent is easy to start. But the experience with Eloquent was better than traditional SQL queries?

---

<div class="post-metadata">

**Author:** ![tflight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/tflight/32/1205_2.png) [@tflight](https://discourse.slimframework.com/u/tflight)\
**Post date:** [November 1, 2016, 6:06pm UTC](https://discourse.slimframework.com/t/orm-and-slimframework/867/5 "2016-11-01T18:06:18Z")

</div>

For me it is. Being able to just write `$user->save();` or `$user->update();` is easier than writing all of the queries. Likewise for relationships doing something like `$invoices = $user->invoices();` is easier for me than writing the join.

---

<div class="post-metadata">

**Author:** ![AndersonDev](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/andersondev/32/50_2.png) [@AndersonDev](https://discourse.slimframework.com/u/AndersonDev)\
**Post date:** [November 1, 2016, 6:15pm UTC](https://discourse.slimframework.com/t/orm-and-slimframework/867/6 "2016-11-01T18:15:54Z")

</div>

Relationships is really cool. Thanks!

---

<div class="post-metadata">

**Author:** ![tflight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/tflight/32/1205_2.png) [@tflight](https://discourse.slimframework.com/u/tflight)\
**Post date:** [November 1, 2016, 6:36pm UTC](https://discourse.slimframework.com/t/orm-and-slimframework/867/7 "2016-11-01T18:36:32Z")

</div>

There are many great tutorial videos about Eloquent at Laracasts. I believe the [Eloquent 101](https://laracasts.com/series/laravel-5-fundamentals/episodes/8) episode is free, to get you started to see what it can do. It is based on Laravel, not Slim, but using Eloquent would be much the same.

---

<div class="post-metadata">

**Author:** ![AndersonDev](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/andersondev/32/50_2.png) [@AndersonDev](https://discourse.slimframework.com/u/AndersonDev)\
**Post date:** [November 1, 2016, 10:06pm UTC](https://discourse.slimframework.com/t/orm-and-slimframework/867/8 "2016-11-01T22:06:36Z")

</div>

Thanks! Do you know some other video lessons?

---

<div class="post-metadata">

**Author:** ![tflight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/tflight/32/1205_2.png) [@tflight](https://discourse.slimframework.com/u/tflight)\
**Post date:** [November 1, 2016, 10:22pm UTC](https://discourse.slimframework.com/t/orm-and-slimframework/867/9 "2016-11-01T22:22:53Z")

</div>

There are probably a couple dozen [lessons on Eloquent at Laracasts](http://discourse.slimframework.com/t/orm-and-slimframework/867/7) which are fantastic. Codecourse has a lesson specifically on [using Eloquent with Slim](https://www.codecourse.com/lessons/laravel-eloquent-with-slim-3) as well as a few other [lessons on Eloquent](https://www.codecourse.com/lessons/search?search=eloquent).

The amazing @akrabat has a [example project using Slim and Eloquent](https://github.com/akrabat/slim-bookshelf), and the official Slim Docs have a cookbook entry for [Using Eloquent with Slim](http://www.slimframework.com/docs/cookbook/database-eloquent.html).

---

<div class="post-metadata">

**Author:** ![dominik.zogg](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/dominik.zogg/32/235_2.png) [@dominik.zogg](https://discourse.slimframework.com/u/dominik.zogg)\
**Post date:** [November 7, 2016, 4:20pm UTC](https://discourse.slimframework.com/t/orm-and-slimframework/867/10 "2016-11-07T16:20:26Z")

</div>

@AndersonDev probably the most powerful, but definitely not the easiest to learn is doctrine [http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/](http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/).

There are Pimple related Services providers which work with Slim3:  
[http://silex.sensiolabs.org/doc/master/providers/doctrine.html](http://silex.sensiolabs.org/doc/master/providers/doctrine.html) (dbal)  
[https://github.com/dflydev/dflydev-doctrine-orm-service-provider](https://github.com/dflydev/dflydev-doctrine-orm-service-provider) (orm)

Regards Dominik

---

<div class="post-metadata">

**Author:** ![AndersonDev](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/andersondev/32/50_2.png) [@AndersonDev](https://discourse.slimframework.com/u/AndersonDev)\
**Post date:** [November 7, 2016, 5:24pm UTC](https://discourse.slimframework.com/t/orm-and-slimframework/867/11 "2016-11-07T17:24:59Z")

</div>

Doctrine is really the most powerful PHP ORM, but for me not so easy to understand and work with. Eloquent is simple and elegant)

---

<div class="post-metadata">

**Author:** ![richp10](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/richp10/32/220_2.png) [@richp10](https://discourse.slimframework.com/u/richp10)\
**Post date:** [November 14, 2016, 11:06am UTC](https://discourse.slimframework.com/t/orm-and-slimframework/867/12 "2016-11-14T11:06:22Z")

</div>

For something lighter weight, I like paris/idiorm - though with php7 / slim 3 the voku/paris fork is working great for me.

I have not seen benchmarks, but I suspect it is faster than Eloquent or Docterine, though has fewer features.
