PHPackages                             bigdropinc/yii2-active-take - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. bigdropinc/yii2-active-take

ActiveYii2-extension[Validation &amp; Sanitization](/categories/validation)

bigdropinc/yii2-active-take
===========================

Provides your ActiveRecords and ActiveQuery with mechanism of raising error when record not found

v2.0(7y ago)1240BSD-3-ClausePHP

Since May 10Pushed 6y ago1 watchersCompare

[ Source](https://github.com/bigdropinc/active-take)[ Packagist](https://packagist.org/packages/bigdropinc/yii2-active-take)[ RSS](/packages/bigdropinc-yii2-active-take/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (2)Dependencies (1)Versions (7)Used By (0)

Active Take
===========

[](#active-take)

Provides your ActiveRecords and ActiveQuery with mechanism of raising error when record not found, not saved or validation failed

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist bigdropinc/yii2-active-take "*"

```

or add

```
"bigdropinc/yii2-active-take": "*"

```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

Please, try to remember how many times you make compare like this

```
if(User::findOne($id) !== null){

}

```

Or something like this

```
if($model->save()){

}

```

OOP best practice said that method should not return null. Much better raise an exception. But in many cases we really need to get null value without raising exceptions. But in many cases no... This extension brings you opportunity to raise and process ActiveRecordExceptions during the interaction with ActiveRecord methods in very simple way. It's can make your code much more simple, clear and readable. It will allowed you to remove ugly and routine compare with null.

### Active Record

[](#active-record)

By using `bigdropinc\take\ActiveRecordTrait` into your ActiveRecord class you got this features:

- all method **"find"** methods will get the pair **"take"** method (*findOne - takeOne, findAll - takeAll*). If find method returns empty result, take method will raise an `RecordNotFoundException`
- method **validateOrFail** will raise `RecordInvalidException` if validate returns false
- method **saveOrFail** will raise `RecordInvalidException` if model has validation errors during save. Also **saveOrFail** will raise `RecordNotSavedException` if model validations was passed but model saving returned false

### Active Query

[](#active-query)

By using `bigdropinc\take\ActiveRecordTrait` into your ActiveRecord class you got this features:

- method **takeOne** will behaves like method **one** but raise an `RecordNotFoundException` if nothing found
- method **takeAll** will behaves like method **all** but raise an `RecordNotFoundException` if nothing found

### Error Handler

[](#error-handler)

To render 404 page while `RecordNotFoundException` was raising, you should modify your main config file:

```
'components' => [
        'errorHandler' => [
            'class' => 'bigdropinc\take\ErrorHandler'
        ],
    ],

```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity67

Established project with proven stability

 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 ~119 days

Total

5

Last Release

2813d ago

Major Versions

v1.2.1 → v2.02018-08-29

### Community

Maintainers

![](https://www.gravatar.com/avatar/d0d934f4d5874afae8503f2410f755f5a005a1dea7f55b123342a1e855a71658?d=identicon)[tv88dn](/maintainers/tv88dn)

---

Top Contributors

[![vadimtrunov](https://avatars.githubusercontent.com/u/11868784?v=4)](https://github.com/vadimtrunov "vadimtrunov (10 commits)")

---

Tags

exceptionyii2extensionactiverecordtakeActiveQuerytakeOnetakeAllRecordNotFound

### Embed Badge

![Health badge](/badges/bigdropinc-yii2-active-take/health.svg)

```
[![Health](https://phpackages.com/badges/bigdropinc-yii2-active-take/health.svg)](https://phpackages.com/packages/bigdropinc-yii2-active-take)
```

###  Alternatives

[kdn/yii2-domain-validator

Domain name validator for Yii 2.

11122.3k1](/packages/kdn-yii2-domain-validator)[nepstor/yii2-datetime-compare-validator

Yii2 validator for compare datetime.

1283.7k1](/packages/nepstor-yii2-datetime-compare-validator)[apexwire/yii2-restclient

Tools to use API as ActiveRecord for Yii2

143.5k](/packages/apexwire-yii2-restclient)

PHPackages © 2026

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