Download the PHP package kobykorman/eloquentify without Composer

On this page you can find all versions of the php package kobykorman/eloquentify. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package eloquentify

Eloquentify for Laravel

👎 Lazy Loading (N+1 queries)

😑 Eager Loading (R+1 queries)

😎 Greedy Loading (1 query)

Why Eloquentify?

⚡ Single Query: N+1/R+1 round trips to the DB become one

💯 Eloquent API: custom SQL in, fully hydrated Eloquent models out

✨ Zero Config: your existing relation methods are all the wiring

Using Eloquent can be costly in terms of how many queries are fired behind the scenes when a model has many relationships. What if we could leverage the database for what it was meant for while retaining the Eloquent experience?

Eloquentify easily transforms the result of a single custom query into nested Eloquent models, so you can continue enjoying the Eloquent API and all of its benefits. And since every one of those replaced queries was a sequential round trip to your database, collapsing them into one is a difference you can see.

Installation

Quick Start

1. Add the trait:

2. Write one query, aggregating each relation into a JSON column named after its relation method:

3. Hydrate:

4. Enjoy real Eloquent models:

How it works

For each column in your result, Eloquentify checks whether the model has a relation method with the same name (it must declare a relation return type, e.g. : HasMany). If it does, the column is decoded as JSON and hydrated recursively: a JSON object for to-one relations, a JSON array for to-many. Every other column becomes a plain attribute. That's the whole contract: column alias = relation method name.

Mistakes fail fast: invalid JSON, shape mismatches (an array where a to-one belongs), and ambiguous columns throw clear exceptions instead of guessing. Empty relations behave as you'd expect: NULL hydrates a to-one relation as null and a to-many as an empty collection, including the [null] arrays that aggregating over a left join produces.

Pivot data (BelongsToMany)

Include a pivot key (or your custom ->as() accessor name) inside each related object and it hydrates into the real pivot model, custom pivot classes included:

JSON functions per database

to-many (JSON array) to-one (JSON object)
PostgreSQL 9.4+ json_agg(...) json_build_object(...)
MySQL 5.7.22+ JSON_ARRAYAGG(...) JSON_OBJECT(...)
SQLite 3.38+ (or 3.9+ compiled with JSON1) json_group_array(...) json_object(...)

Requirements

Limitations

New in v2 (for v1 users)

v2 replaced v1's column prefixes with JSON aggregation (json_agg & friends). In one move:

License

This library is open-sourced software licensed under the MIT license.


All versions of eloquentify with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
laravel/framework Version ^11.0|^12.0|^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package kobykorman/eloquentify contains the following files

Loading the files please wait ...