PHPackages                             baha2odeh/yii2-precognition - 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. [Framework](/categories/framework)
4. /
5. baha2odeh/yii2-precognition

ActiveYii2-extension[Framework](/categories/framework)

baha2odeh/yii2-precognition
===========================

Yii2 Precognition

v0.001(1y ago)0217Apache-2.0PHP

Since Nov 5Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Baha2Odeh/yii2-precognition)[ Packagist](https://packagist.org/packages/baha2odeh/yii2-precognition)[ RSS](/packages/baha2odeh-yii2-precognition/feed)WikiDiscussions master Synced 3w ago

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

Yii2 Precognition
=================

[](#yii2-precognition)

Yii2 Precognition

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

[](#installation)

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

Either run

```
php composer.phar require --prefer-dist baha2odeh/yii2-precognition "*"

```

or add

```
"baha2odeh/yii2-precognition": "*"

```

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

Usage
-----

[](#usage)

Once the extension is installed, simply use it in your code by:

add this trait to the ActiveRecord

```
class User extends ActiveRecord {

...
use \Baha2Odeh\Precognition\ValidateTrait;
...
```

You can also use this method with a custom model

`$this->handlePrecognition();`

This method stops request processing if there are no errors and the request is a 'precognition' request, meaning it's not an actual submission but a preliminary check.

```
class LoginForm extends Model {

...
use \Baha2Odeh\Precognition\ValidateTrait;
...

public function process(){
    ...
    if(!$this->validate()){
        return false;
    }
    $this->handlePrecognition();
    ...
}
```

Last step to change the restful response serializer to handle the 'precognition' requests

```
class UserController extends \yii\rest\ActiveController
{
    ...
    public $serializer = \Baha2Odeh\Precognition\Serializer::class;
    ...
```

in frontend side you have to add a new header in the axios requests to allow Yii to return 'precognition' response in case the submit was failed

```
import axios from 'axios'
import { client } from 'laravel-precognition-vue';

axios.interceptors.request.use(config => {
config.headers['precognition-on-submit'] = "true"
return config
})

client.use(axios)
```

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity29

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

599d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2823958?v=4)[Bahaa Odeh](/maintainers/Baha2Odeh)[@Baha2Odeh](https://github.com/Baha2Odeh)

---

Top Contributors

[![Baha2Odeh](https://avatars.githubusercontent.com/u/2823958?v=4)](https://github.com/Baha2Odeh "Baha2Odeh (20 commits)")

---

Tags

yii2extension

### Embed Badge

![Health badge](/badges/baha2odeh-yii2-precognition/health.svg)

```
[![Health](https://phpackages.com/badges/baha2odeh-yii2-precognition/health.svg)](https://phpackages.com/packages/baha2odeh-yii2-precognition)
```

###  Alternatives

[miloschuman/yii2-highcharts-widget

Highcharts widget for Yii 2 Framework.

1641.6M15](/packages/miloschuman-yii2-highcharts-widget)[skeeks/cms

SkeekS CMS — control panel and tools based on php framework Yii2

13725.7k50](/packages/skeeks-cms)

PHPackages © 2026

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