PHPackages                             cycle/active-record - 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. cycle/active-record

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

cycle/active-record
===================

Provides a simple way to work with your database using Active Record pattern and Cycle ORM

v1.1.1(8mo ago)671.3k↑700%[1 PRs](https://github.com/cycle/active-record/pulls)2MITPHPPHP &gt;=8.1CI passing

Since May 2Pushed 8mo ago3 watchersCompare

[ Source](https://github.com/cycle/active-record)[ Packagist](https://packagist.org/packages/cycle/active-record)[ Docs](https://cycle-orm.dev)[ GitHub Sponsors](https://github.com/sponsors/cycle)[ RSS](/packages/cycle-active-record/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelog (10)Dependencies (22)Versions (18)Used By (2)

 [   ![CycleORM Logo](https://github.com/cycle/.github/raw/main/logo/words-vector-light.svg?raw=true)  ](https://cycle-orm.dev)

[![Codecov Coverage](https://camo.githubusercontent.com/c98de3ad091aff5a4d77285b3149d1efff3a1b14abf06f7d47b64dd506685bfc/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6379636c652f6163746976652d7265636f72643f7374796c653d666c61742d737175617265266c6f676f3d636f6465636f76)](https://app.codecov.io/gh/cycle/active-record)[![Type Coverage](https://camo.githubusercontent.com/4611dc11a7de4117cf280d773b6924f97f319516e3581e5074ee14b851697c0d/68747470733a2f2f73686570686572642e6465762f6769746875622f6379636c652f6163746976652d7265636f72642f636f7665726167652e737667)](https://shepherd.dev/github/cycle/active-record)[![Mutation testing badge](https://camo.githubusercontent.com/252c3e0e11e3ae5511332955ca17231e8c15775c39065ac8f3abe4e7c1b523b5/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742d737175617265266c6162656c3d6d75746174696f6e25323073636f72652675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d2532466379636c652532466163746976652d7265636f72642532466d6173746572)](https://dashboard.stryker-mutator.io/reports/github.com/cycle/active-record/master)[![MetaStorm plugin](https://camo.githubusercontent.com/0cca986c80223fdfdba54874118a66dc379ffd57215b6c1f7482fe3c6c15044c/68747470733a2f2f696d672e736869656c64732e696f2f7374617469632f76313f6c6162656c3d4d6574612b53746f726d266d6573736167653d616e6e6f746174656426636f6c6f723d303038383830267374796c653d666c61742d737175617265266c6f676f3d646174613a696d6167652f737667253262786d6c3b6261736536342c50484e325a79423361575230614430694d5445784969426f5a576c6e61485139496a45784d534967646d6c6c64304a76654430694d434177494445784d5341784d54456949475a7062477739496d3576626d5569494868746247357a50534a6f644852774f693876643364334c6e637a4c6d39795a7938794d4441774c334e325a79492b50484268644767675a443069545459774c6a51324d5463674f45777a4d4334784e6a5530494467754d6a51334f554d794e7934794e4459674f4334794e7a45334f5341794e4334324e4467674d5441754d5441314944497a4c6a59304e7941784d6934344e446331544441754e444d774e546b674e7a59754f444d784e454d744d5334794e4451314f5341344d5334304d6a4134494449754d5463344d4455674f4459754d6a63784d7941334c6a41324d7a557a494467324c6a497a4d544e4d4d7a49754d5445354e7941344e6934774d6a597a54444d314c6a51784e4463674e7a59754f546b3554446b754f44637a4f5445674e7a63754d6a413454444d784c6a59794e546b674d5463754d6a4d324d6b77314e7934784e6a5932494445334c6a41794e7a4e4d4e6a41754e4459784e794134576949675a6d6c736244306949304647516a46434d794976506a78775958526f49475139496b30304f5334304d545135494445774d6934354f546c4d4e7a6b754e7a45794d6941784d4449754f546b35517a67794c6a597a4d5463674d5441794c6a6b354f5341344e5334794e445132494445774d5334784f4463674f4459754d6a593449446b344c6a51314d6a6c4d4d5445774c6a41784d79417a4e4334304e544930517a45784d5334334d6a59674d6a6b754f4463324f4341784d4467754d7a517a494449304c6a6b354f4455674d54417a4c6a51314e7941794e4334354f546731544463344c6a51774d4451674d6a51754f546b344e5577334e5334774d7a453249444d7a4c6a6b354f44564d4d5441774c6a55334d79417a4d7934354f546731544463344c6a4d794e544d674f544d754f546b35544455794c6a63344d7a63674f544d754f546b35544451354c6a51784e446b674d5441794c6a6b354f566f6949475a706247773949694e42526b4978516a4d694c7a3438634746306143426b50534a4e4d6a49674e6a464d4f4459674f4577314e7941314d4577344f5334354f546b33494451354c6a6b354f54644d4d6a59674d54417a544455314944597853444979576949675a6d6c736244306949304d334e5451314d434976506a777663335a6e50673d3d)](https://github.com/xepozz/meta-storm-idea-plugin)

[![Discord](https://camo.githubusercontent.com/82e12441f19f24f02114101c123dc4aae710b4e80f4ec464a85195f8d56cdd71/68747470733a2f2f696d672e736869656c64732e696f2f646973636f72642f3533383131343837353537303931333239303f7374796c653d666c61742d737175617265266c6f676f3d646973636f7264266c6162656c436f6c6f723d373238396439266c6f676f436f6c6f723d776869746526636f6c6f723d333934353664)](https://discord.gg/spiralphp)[![Follow on Twitter (X)](https://camo.githubusercontent.com/91c1c3b545d03e0c79f91364259b2814308d2b3786c67c8578740879528ff37c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2d466f6c6c6f772d626c61636b3f7374796c653d666c61742d737175617265266c6f676f3d58)](https://x.com/intent/follow?screen_name=SpiralPHP)

Active Record Implementation for Cycle ORM
==========================================

[](#active-record-implementation-for-cycle-orm)

This library extends Cycle ORM by integrating the [Active Record pattern](https://en.wikipedia.org/wiki/Active_record_pattern), providing developers with an intuitive, object-centric way to interact with databases.

Unlike Cycle ORM's default Data Mapper pattern, which separates the in-memory object representations from database operations, Active Record combines data access and business logic in a single entity.

This allows for more straightforward and rapid development cycles, particularly for simpler CRUD operations, by enabling direct data manipulation through the object's properties and methods.

🚩 Prerequisites
---------------

[](#-prerequisites)

Before you begin, ensure your development environment meets the following requirements:

- **PHP Version:** 8.1 or higher
- One of the Cycle ORM adapters:
    - [`spiral/cycle-bridge`](https://github.com/spiral/cycle-bridge) official Cycle ORM adapter for the [Spiral Framework](https://github.com/spiral/framework)
    - [`yiisoft/yii-cycle`](https://github.com/yiisoft/yii-cycle) — official Cycle ORM adapter for the [Yii 3](https://www.yiiframework.com)
    - [`wayofdev/laravel-cycle-orm-adapter`](https://github.com/wayofdev/laravel-cycle-orm-adapter) — package managed by [@wayofdev](https://github.com/wayofdev) for the [Laravel](https://laravel.com) 10.x or higher.

💿 Installation
--------------

[](#-installation)

The preferred way to install this package is through [Composer](https://getcomposer.org/).

```
composer require cycle/active-record
```

[![PHP Version Require](https://camo.githubusercontent.com/a9c996ae18a690f5ac70cc1ba93e73b5e8d728b11b9a68f50e30e38d6bea928b/68747470733a2f2f706f7365722e707567782e6f72672f6379636c652f6163746976652d7265636f72642f726571756972652f7068703f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cycle/active-record)[![Latest Stable Version](https://camo.githubusercontent.com/932dc3fc129fa5ec1631d6748156dba032a9076365ccc45478ec63744e92b3ab/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6379636c652f6163746976652d7265636f72643f267374796c653d666c61742d737175617265)](https://packagist.org/packages/cycle/active-record)[![License](https://camo.githubusercontent.com/58254af4548cd43d909dbab1d36bd702d8418089308c8081b9e706f67b15c053/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6379636c652f6163746976652d7265636f72642e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/cc5c9288a0d646c6f6865239be9b4febed5fd280d81e691ca0a9f2c6edb66bf6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6379636c652f6163746976652d7265636f72643f267374796c653d666c61742d737175617265)](https://packagist.org/packages/cycle/active-record)

After package install you need to, optionally, register bootloader / service-provider in your application.

### → Spiral Framework

[](#-spiral-framework)

Note

If you are installing the package on the Spiral Framework with the [spiral-packages/discoverer](https://github.com/spiral-packages/discoverer) package, then you don't need to register bootloader by yourself. It will be registered automatically.

Update Bootloader list in your application configuration:

```
