{"id":36982560,"url":"https://github.com/folded-php/orm","last_synced_at":"2026-01-13T22:52:39.719Z","repository":{"id":62506135,"uuid":"293627967","full_name":"folded-php/orm","owner":"folded-php","description":"An ORM for you web app.","archived":false,"fork":false,"pushed_at":"2020-10-17T07:58:00.000Z","size":90,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-14T04:45:59.934Z","etag":null,"topics":["eloquent","laravel","orm","php"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/folded/orm","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/folded-php.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-07T20:39:18.000Z","updated_at":"2021-03-02T12:33:16.000Z","dependencies_parsed_at":"2022-11-02T12:30:54.077Z","dependency_job_id":null,"html_url":"https://github.com/folded-php/orm","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/folded-php/orm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/folded-php%2Form","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/folded-php%2Form/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/folded-php%2Form/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/folded-php%2Form/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/folded-php","download_url":"https://codeload.github.com/folded-php/orm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/folded-php%2Form/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28402205,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eloquent","laravel","orm","php"],"created_at":"2026-01-13T22:52:38.729Z","updated_at":"2026-01-13T22:52:39.708Z","avatar_url":"https://github.com/folded-php.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# folded/orm\n\nA standalone Eloquent ORM for you web app.\n\n[![Packagist License](https://img.shields.io/packagist/l/folded/orm)](https://github.com/folded-php/orm/blob/master/LICENSE) [![Packagist PHP Version Support](https://img.shields.io/packagist/php-v/folded/orm)](https://github.com/folded-php/orm/blob/master/composer.json#L14) [![Packagist Version](https://img.shields.io/packagist/v/folded/orm)](https://packagist.org/packages/folded/orm) [![Build Status](https://travis-ci.com/folded-php/orm.svg?branch=master)](https://travis-ci.com/folded-php/orm) [![Maintainability](https://api.codeclimate.com/v1/badges/9e72165b7dbf2a78b7db/maintainability)](https://codeclimate.com/github/folded-php/orm/maintainability) [![TODOs](https://img.shields.io/endpoint?url=https://api.tickgit.com/badge?repo=github.com/folded-php/orm)](https://www.tickgit.com/browse?repo=github.com/folded-php/orm)\n\n## Summary\n\n- [About](#about)\n- [Features](#features)\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Examples](#examples)\n- [Version support](#version-support)\n- [Credits](#credits)\n\n## About\n\nProvides a standalone package to use Eloquent model inside your web app, with minimal configuration.\n\nFolded is a constellation of packages to help you setting up a web app easily, using ready to plug in packages.\n\n- [folded/action](https://github.com/folded-php/action): A way to organize your controllers for your web app.\n- [folded/config](https://github.com/folded-php/config): Configuration utilities for your PHP web app.\n- [folded/crypt](https://github.com/folded-php/crypt): Encrypt and decrypt strings for your web app.\n- [folded/exception](https://github.com/folded-php/exception): Various kind of exception to throw for your web app.\n- [folded/history](https://github.com/folded-php/history): Manipulate the browser history for your web app.\n- [folded/request](https://github.com/folded-php/request): Request utilities, including a request validator, for your PHP web app.\n- [folded/routing](https://github.com/folded-php/routing): Routing functions for your PHP web app.\n- [folded/session](https://github.com/folded-php/session): Session functions for your web app.\n- [folded/view](https://github.com/folded-php/view): View utilities for your PHP web app.\n\n## Features\n\n- All the features provided by Laravel's Eloquent\n- Eager load the engine, so if a request does not call an eloquent method, it is never booted\n- Enable the Eloquent events only if you need them\n\n## Requirements\n\n- PHP version \u003e= 7.4.0\n- Composer installed\n- Knowledge with [Eloquent ORM](https://laravel.com/docs/7.x/eloquent)\n\n## Installation\n\n- [1. Install the package](#1-instal-the-package)\n- [2. Add a database connection](#2-add-a-database-connection)\n- [3. Create your model class](#3-create-your-model-file)\n\n### 1. Install the package\n\nIn your root directory, run this command:\n\n```bash\ncomposer require folded/orm\n```\n\n### 2. Add a database connection\n\nCall this method before using your Eloquent model to provide with your database connection information:\n\n```php\nuse function Folded\\addDatabaseConnection;\n\naddDatabaseConnection([\n  \"driver\" =\u003e \"mysql\",\n  \"host\" =\u003e \"localhost\",\n  \"username\" =\u003e \"root\",\n  \"password\" =\u003e \"root\",\n]);\n```\n\nYou can see a complete list of options in the example [put example here].\n\n### 3. Create your model file\n\nAnywhere you want, create a class to map your table.\n\n```php\nnamespace App;\n\nuse Folded\\Model;\n\nclass Post extends Model\n{\n  //\n}\n```\n\n## Examples\n\nAs 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).\n\n- [1. Get all the data from your model](#1-get-all-the-data-from-your-model)\n- [2. Add more information to the database connection](#2-add-more-information-to-the-database-connection)\n- [3. Enable/disable eloquent events](#3-enable-disable-eloquent-events)\n- [4. Go to a specific page before paginating](#4-go-to-a-specific-page-before-paginating)\n\n### 1. Get all the data from your model\n\nIn this example, we will use our `Post` class to get all the posts.\n\n```php\nuse App\\Post;\n\n$posts = Post::all();\n\nforeach ($posts as $post) {\n  echo \"{$post-\u003etitle}: {$post-\u003eexcerpt}\";\n}\n```\n\n### 2. Add more information to the database connection\n\nIn this example, we will see a complete list of keys you can set on the database connection.\n\n```php\nuse function Folded\\addDatabaseConnection;\n\naddDatabaseConnection([\n  \"driver\" =\u003e \"mysql\",\n  \"host\" =\u003e \"localhost\",\n  \"database\" =\u003e \"my-blog\",\n  \"username\" =\u003e \"root\",\n  \"password\" =\u003e \"root\",\n  \"charset\" =\u003e \"utf8mb4\",\n  \"collation\" =\u003e \"utf8mb4_general_ci\",\n  \"prefix\" =\u003e \"wp_\",\n]);\n```\n\n### 3. Enable/disable eloquent events\n\nIn 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).\n\n```php\nuse function Folded\\enableEloquentEvents;\nuse function Folded\\disableEloquentEvents;\n\nenableEloquentEvents();\ndisableEloquentEvents();\n```\n\n### 4. Go to a specific page before paginating\n\nIn 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.\n\n```php\n$posts = Post::toPage(2)-\u003epaginate(15);\n```\n\nThe page number should come for example from the query strings, like when the user browse `/post?page=2`.\n\nHowever, 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:\n\n```php\n$posts = Post::where(\"author\", \"foo\")-\u003etoPage(2)-\u003epaginate(15);\n```\n\nTo fix this issue, use the verbose version of `-\u003epaginate()`:\n\n```php\n$posts = Post::where(\"author\", \"foo\")-\u003epaginate(15, [\"*\"], \"page\", 2); // 2 is the page number\n```\n\n## Version support\n\n|        | 7.3 | 7.4 | 8.0 |\n| ------ | --- | --- | --- |\n| v0.1.0 | ❌  | ✔️  | ❓  |\n| v0.1.1 | ❌  | ✔️  | ❓  |\n| v0.2.0 | ❌  | ✔️  | ❓  |\n| v0.2.1 | ❌  | ✔️  | ❓  |\n| v0.2.2 | ❌  | ✔️  | ❓  |\n\n## Credits\n\nThis library would not have see the light without the impressive work from Matt Stauffer with [Torch](https://github.com/mattstauffer/Torch).\n\nTorch is a project to provide instructions and examples for using Illuminate components as standalone components in non-Laravel applications, including Eloquent.\n\nGive 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)!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffolded-php%2Form","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffolded-php%2Form","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffolded-php%2Form/lists"}