PHPackages                             folded/orm - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. folded/orm

ActiveLibrary[Database &amp; ORM](/categories/database)

folded/orm
==========

A standalone Eloquent ORM for you web app.

v0.2.2(5y ago)112MITPHPPHP &gt;=7.4.0

Since Sep 10Pushed 5y ago1 watchersCompare

[ Source](https://github.com/folded-php/orm)[ Packagist](https://packagist.org/packages/folded/orm)[ RSS](/packages/folded-orm/feed)WikiDiscussions master Synced 5d ago

READMEChangelogDependencies (7)Versions (6)Used By (0)

folded/orm
==========

[](#foldedorm)

A standalone Eloquent ORM for you web app.

[![Packagist License](https://camo.githubusercontent.com/002c870702958fabfcace5b692ba305cb286c17459c1294fe0c8467219892676/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f666f6c6465642f6f726d)](https://github.com/folded-php/orm/blob/master/LICENSE) [![Packagist PHP Version Support](https://camo.githubusercontent.com/8fa524146c54ae88ad9b6c8e7908b27e6a9a3d89693b96ec9b376ff6e5b089d8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f666f6c6465642f6f726d)](https://github.com/folded-php/orm/blob/master/composer.json#L14) [![Packagist Version](https://camo.githubusercontent.com/3a46586e3f77fb33098c06f3ff09cf0395b9a3db3bb3a073262170296f482a18/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f666f6c6465642f6f726d)](https://packagist.org/packages/folded/orm) [![Build Status](https://camo.githubusercontent.com/6fbbef2fdf8168ae4c1538cfb1dcf786cfe8fd3c4a669226051c7b960e68f437/68747470733a2f2f7472617669732d63692e636f6d2f666f6c6465642d7068702f6f726d2e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/folded-php/orm) [![Maintainability](https://camo.githubusercontent.com/8a7364f9779685399492e4639197b1d79f20e979d9ce4fe0bc556c6a447f47e0/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f39653732313635623764626632613738623764622f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/folded-php/orm/maintainability) [![TODOs](https://camo.githubusercontent.com/fe809cd72ca8440ee8c7a3a93c73166659c039bc794a803a349ebc72f13a7efa/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d68747470733a2f2f6170692e7469636b6769742e636f6d2f62616467653f7265706f3d6769746875622e636f6d2f666f6c6465642d7068702f6f726d)](https://www.tickgit.com/browse?repo=github.com/folded-php/orm)

Summary
-------

[](#summary)

- [About](#about)
- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [Examples](#examples)
- [Version support](#version-support)
- [Credits](#credits)

About
-----

[](#about)

Provides a standalone package to use Eloquent model inside your web app, with minimal configuration.

Folded is a constellation of packages to help you setting up a web app easily, using ready to plug in packages.

- [folded/action](https://github.com/folded-php/action): A way to organize your controllers for your web app.
- [folded/config](https://github.com/folded-php/config): Configuration utilities for your PHP web app.
- [folded/crypt](https://github.com/folded-php/crypt): Encrypt and decrypt strings for your web app.
- [folded/exception](https://github.com/folded-php/exception): Various kind of exception to throw for your web app.
- [folded/history](https://github.com/folded-php/history): Manipulate the browser history for your web app.
- [folded/request](https://github.com/folded-php/request): Request utilities, including a request validator, for your PHP web app.
- [folded/routing](https://github.com/folded-php/routing): Routing functions for your PHP web app.
- [folded/session](https://github.com/folded-php/session): Session functions for your web app.
- [folded/view](https://github.com/folded-php/view): View utilities for your PHP web app.

Features
--------

[](#features)

- All the features provided by Laravel's Eloquent
- Eager load the engine, so if a request does not call an eloquent method, it is never booted
- Enable the Eloquent events only if you need them

Requirements
------------

[](#requirements)

- PHP version &gt;= 7.4.0
- Composer installed
- Knowledge with [Eloquent ORM](https://laravel.com/docs/7.x/eloquent)

Installation
------------

[](#installation)

- [1. Install the package](#1-instal-the-package)
- [2. Add a database connection](#2-add-a-database-connection)
- [3. Create your model class](#3-create-your-model-file)

### 1. Install the package

[](#1-install-the-package)

In your root directory, run this command:

```
composer require folded/orm
```

### 2. Add a database connection

[](#2-add-a-database-connection)

Call this method before using your Eloquent model to provide with your database connection information:

```
use function Folded\addDatabaseConnection;

addDatabaseConnection([
  "driver" => "mysql",
  "host" => "localhost",
  "username" => "root",
  "password" => "root",
]);
```

You can see a complete list of options in the example \[put example here\].

### 3. Create your model file

[](#3-create-your-model-file)

Anywhere you want, create a class to map your table.

```
namespace App;

use Folded\Model;

class Post extends Model
{
  //
}
```

Examples
--------

[](#examples)

As this library relies on Eloquent, you will find a useful amount of information about all the capability of this ORM in [the official documentation](https://laravel.com/docs/7.x/eloquent).

- [1. Get all the data from your model](#1-get-all-the-data-from-your-model)
- [2. Add more information to the database connection](#2-add-more-information-to-the-database-connection)
- [3. Enable/disable eloquent events](#3-enable-disable-eloquent-events)
- [4. Go to a specific page before paginating](#4-go-to-a-specific-page-before-paginating)

### 1. Get all the data from your model

[](#1-get-all-the-data-from-your-model)

In this example, we will use our `Post` class to get all the posts.

```
use App\Post;

$posts = Post::all();

foreach ($posts as $post) {
  echo "{$post->title}: {$post->excerpt}";
}
```

### 2. Add more information to the database connection

[](#2-add-more-information-to-the-database-connection)

In this example, we will see a complete list of keys you can set on the database connection.

```
use function Folded\addDatabaseConnection;

addDatabaseConnection([
  "driver" => "mysql",
  "host" => "localhost",
  "database" => "my-blog",
  "username" => "root",
  "password" => "root",
  "charset" => "utf8mb4",
  "collation" => "utf8mb4_general_ci",
  "prefix" => "wp_",
]);
```

### 3. Enable/disable eloquent events

[](#3-enabledisable-eloquent-events)

In this example, we will enable, then disable the Eloquent events system. Learn more on [the official documentation](https://laravel.com/docs/7.x/eloquent#events).

```
use function Folded\enableEloquentEvents;
use function Folded\disableEloquentEvents;

enableEloquentEvents();
disableEloquentEvents();
```

### 4. Go to a specific page before paginating

[](#4-go-to-a-specific-page-before-paginating)

In this example, we will instruct the paginator to go to a certain page before paginating. As we are not in Laravel, this is required to correctly returns the items according to the browsed page.

```
$posts = Post::toPage(2)->paginate(15);
```

The page number should come for example from the query strings, like when the user browse `/post?page=2`.

However, for technical reasons, I could not find how to provide the same method after you call eloquent methods before. Which means that the following code will not work:

```
$posts = Post::where("author", "foo")->toPage(2)->paginate(15);
```

To fix this issue, use the verbose version of `->paginate()`:

```
$posts = Post::where("author", "foo")->paginate(15, ["*"], "page", 2); // 2 is the page number
```

Version support
---------------

[](#version-support)

7.37.48.0v0.1.0❌✔️❓v0.1.1❌✔️❓v0.2.0❌✔️❓v0.2.1❌✔️❓v0.2.2❌✔️❓Credits
-------

[](#credits)

This library would not have see the light without the impressive work from Matt Stauffer with [Torch](https://github.com/mattstauffer/Torch).

Torch is a project to provide instructions and examples for using Illuminate components as standalone components in non-Laravel applications, including Eloquent.

Give this man an ice cold beer, [a star](https://github.com/mattstauffer/Torch) to this great idea, and follow him on Twitter [@stauffermatt](https://twitter.com/stauffermatt)!

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~8 days

Total

5

Last Release

2042d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/15908747?v=4)[Anwar](/maintainers/khalyomede)[@khalyomede](https://github.com/khalyomede)

---

Top Contributors

[![khalyomede](https://avatars.githubusercontent.com/u/15908747?v=4)](https://github.com/khalyomede "khalyomede (29 commits)")

---

Tags

eloquentlaravelormphp

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/folded-orm/health.svg)

```
[![Health](https://phpackages.com/badges/folded-orm/health.svg)](https://phpackages.com/packages/folded-orm)
```

###  Alternatives

[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k7.2M71](/packages/mongodb-laravel-mongodb)[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[dyrynda/laravel-cascade-soft-deletes

Cascading deletes for Eloquent models that implement soft deletes

1.2k3.1M5](/packages/dyrynda-laravel-cascade-soft-deletes)[tightenco/parental

A simple eloquent trait that allows relationships to be accessed through child models.

1.5k1.8M5](/packages/tightenco-parental)[watson/validating

Eloquent model validating trait.

9723.3M47](/packages/watson-validating)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8703.0M17](/packages/yajra-laravel-oci8)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
