Download the PHP package activix/simple-eloquent without Composer
On this page you can find all versions of the php package activix/simple-eloquent. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package simple-eloquent
Simple eloquent extension for Laravel
This extension presents some methods for eloquent ORM in order to reduce time and memory consumption.
Sometimes application doesn't need all of eloquent overhead. It just requires to retrieve model's attributes with relations and nothing more.
In this case this methods might be enough useful for you.
Extension supports:
- eloquent relations
- illuminate pagination
- PDO::FETCH_OBJ and PDO::FETCH_ASSOC fetch modes
Requirements
laravel >= 5.3
Installation
Run
or add this code line to the require
section of your composer.json
file:
Usage
Just use SimpleEloquent trait in your model. If you want to get models with relations attach SimpleEloquent trait to related models as well.
Then use simple() method in chain of methods calls.
Profit
Example 1 - users with details; 50 per page
Time | Memory consumption | |
---|---|---|
get() | 0.62s | 6.0mb |
simple()->get() | 0.19s | 3.0mb |
Example 2 - select models with 5-level relation
Time | Memory consumption | |
---|---|---|
get() | 1.48s | 28.5mb |
simple()->get() | 0.47s | 15.5mb |
Example 3 - let's select 1000 models
Time | Memory consumption | |
---|---|---|
get() | 0.22s | 2.0mb |
simple()->get() | 0.06s | 1.1mb |
What do you lose?
Since this extension provides less expensive methods you'll definitely lose some functionality. Basic methods return collection of eloquent models in contrast to new functionality which returns collection of stdClasses|arrays. This example will show the difference between results.
get() returns
simple()->get() returns
Since you'll get stdClasses|arrays you won't reach out to casting, appends, guarded/fillable, crud and another possibilities. That's why new methods are much faster :smirk:
All versions of simple-eloquent with dependencies
illuminate/database Version ^8.0|^9.0|^10.0
illuminate/support Version ^8.0|^9.0|^10.0
illuminate/pagination Version ^8.0|^9.0|^10.0