PHPackages                             vigihdev/yii2-bridge-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. vigihdev/yii2-bridge-active-record

ActiveLibrary

vigihdev/yii2-bridge-active-record
==================================

Enhanced Active Record bridge for Yii2 with service container integration, validation, caching, and multilingual support

04PHPCI passing

Since Nov 9Pushed 6mo agoCompare

[ Source](https://github.com/vigihdev/yii2-bridge-active-record)[ Packagist](https://packagist.org/packages/vigihdev/yii2-bridge-active-record)[ RSS](/packages/vigihdev-yii2-bridge-active-record/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Yii2 Bridge Active Record
=========================

[](#yii2-bridge-active-record)

[![Latest Stable Version](https://camo.githubusercontent.com/c61cb649334b8ca9c51224486ba5c3d56586a79a7bf6577dd595e80156d494e0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f76696769686465762f796969322d6272696467652d6163746976652d7265636f72642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vigihdev/yii2-bridge-active-record)[![Total Downloads](https://camo.githubusercontent.com/01f19ec2122dae942cafffc7d7cf7945134ba2aa7c0b611f5ed1baec6f494c4f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f76696769686465762f796969322d6272696467652d6163746976652d7265636f72642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vigihdev/yii2-bridge-active-record)[![License](https://camo.githubusercontent.com/3f10ae0793f906b7a81797e6b4a023e7c77d2afd532826792995434083bf31f7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f76696769686465762f796969322d6272696467652d6163746976652d7265636f72642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vigihdev/yii2-bridge-active-record)[![Build Status](https://camo.githubusercontent.com/9f4c73933a79a354e80c05f1b58f5d15ee0e805c90465b23a6df34dbd26b05f9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f76696769686465762f796969322d6272696467652d6163746976652d7265636f72642f707573682e796d6c3f6272616e63683d6d61696e267374796c653d666c61742d737175617265)](https://github.com/vigihdev/yii2-bridge-active-record/actions)

Enhanced Active Record bridge for modern PHP applications, integrating a powerful service container, advanced validation, caching, and multilingual support. This library provides a flexible and robust ORM layer, designed to be easily integrated into any project requiring a solid data persistence solution.

Features
--------

[](#features)

- **Service Container Integration**: Decouples database connections, making your models more portable and testable.
- **Modern Validation**: Leverages `yiisoft/validator` for powerful and flexible validation rules (via `vigihdev/yii2-bridge-validator`).
- **Event-Driven Architecture**: Dispatch events on `AfterInsert`, `AfterUpdate`, and `AfterDelete` to hook into the model lifecycle.
- **Seamless Relations**: Easily define and query relationships between your entities.
- **Modern Data Types**: Automatic handling of `DateTimeImmutable` for date/time fields.

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

[](#installation)

Install the package via [Composer](https://getcomposer.org/):

```
composer require vigihdev/yii2-bridge-active-record
```

Basic Usage
-----------

[](#basic-usage)

First, ensure your service container is configured to provide database connections. This library relies on `vigihdev/yii2-bridge-db` for connection management.

### 1. Create a Base Model

[](#1-create-a-base-model)

Create your own base model that extends `VigihDev\Yii2Bridge\ActiveRecord\BaseActiveRecord` and specifies the database service name.

```
