PHPackages                             ahmadasjad/yii1plushyii2 - 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. ahmadasjad/yii1plushyii2

ActiveLibrary

ahmadasjad/yii1plushyii2
========================

A library to use yii1 and Yii2 together

2644PHP

Since Jul 13Pushed 4y agoCompare

[ Source](https://github.com/ahmadasjad/yii1plusyii2)[ Packagist](https://packagist.org/packages/ahmadasjad/yii1plushyii2)[ RSS](/packages/ahmadasjad-yii1plushyii2/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

yii1 Plus Yii2
==============

[](#yii1-plus-yii2)

We can achieve this in two steps

- Using base controller from Yii1
- Using base controller from Yii2

For every step, I have created two repository. We'll use it accordingly

### Steps to follow

[](#steps-to-follow)

> \*\*: Mandatory

> \*: Somehow mandatory

> (no star): optional

- Make your project composer compatible and use yii1 with composer dependency\*\*

    Add classmap in autoloader, and put all you resources folder in its value

    `composer dump-autoload`

    Resolve all warning for **Ambiguous class resolution**
- Install my both repo using composer\*\*

    ```
    composer require ahmadasjad/yii1plushyii2
    composer require ahmadasjad/yii2plusyii1

    ```
- Create two branch of *git* one with *yii1Controller* and another with *yii2Controller*
- Create a yii2 config directory inside site/protected/config/`yii2` \*
- Copy `index.php` and `Yii2Yii1.php` file from `ahmadasjad/yii2plusyii1` repo to your *site* directory or customize index.php according to your files structure and config \*
- Create a custom Controller and extend it from `\ahmadasjad\yii1PlusYii2\Controller` \*\*

    Now, in every controller extend from your customized controller. This will help you to change only inside your base custom controller in future when you use the controller from Yii2
- Replace View class\*

    Add this to your Yii2 config

    ```
    'components' => [
        'view' => ['class' => \ahmadasjad\yii1PlusYii2\View::class],
    ],
    ```
- Register Yii2 assets in yii1\*

    Add `Yii::$app->getView()->registerYii2Assets();` inside the layout or view file. This will create a bridge in publishing Yii2 assets in yii1.
- add `return` before `render('yourView', ['model' => $model])` call inside every controller.
- Make your controllers namespaced \*:
- Add following function inside the config while bootstrapping the app:

    ```
    function() {
        //Set modelName converter for Yii1 models class in html form
        CHtml::setModelNameConverter(function ($model){
            $className = get_class($model);
            $reflector = new ReflectionClass($className);
            return $reflector->getShortName();
        });
    }
    ```

    Now your config should look like:

    ```
    return [
        ...,
        'aliases' => [...],
        'bootstrap' => [
            ...,
            function() {
                //Set modelName converter for Yii1 models class in html form
                CHtml::setModelNameConverter(function ($model){
                    $className = get_class($model);
                    $reflector = new ReflectionClass($className);
                    return $reflector->getShortName();
                });
            },
            ...,
        ],
        'components' => [...],
        ...
    ];
    ```

### Tips

[](#tips)

- Remove unnecessary codes generated by GII crud like `index.php`, `_view.php` files from view and `actionIndex()` method from controller

### Problems and solutions

[](#problems-and-solutions)

### Conversion

[](#conversion)

- [zii.widgets.jui.CJuiDatePicker -&gt; yii\\jui\\DatePicker\\DatePicker](docs/datePicker.md)
- [CStarRating -&gt; \\yii2mod\\rating\\StarRating](docs/starRating.md)
- [zii.widgets.jui.CJuiAutoComplete -&gt; \\yii\\jui\\AutoComplete](docs/autocomplete.md)
- [zii.widgets.CDetailView -&gt; \\yii\\widgets\\DetailView](docs/detailView.md)

### Links helped during the development

[](#links-helped-during-the-development)

-
-
-
-

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community6

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/7730b61d24eb0885673bcaa4a9662fa1b2e0e7bbd56d42acfd12a33f06aa21f4?d=identicon)[ahmadasjad](/maintainers/ahmadasjad)

---

Top Contributors

[![ahmadasjad](https://avatars.githubusercontent.com/u/7436311?v=4)](https://github.com/ahmadasjad "ahmadasjad (15 commits)")

---

Tags

phpyii1yii1-and-yii2yii2yii2-and-yii1

### Embed Badge

![Health badge](/badges/ahmadasjad-yii1plushyii2/health.svg)

```
[![Health](https://phpackages.com/badges/ahmadasjad-yii1plushyii2/health.svg)](https://phpackages.com/packages/ahmadasjad-yii1plushyii2)
```

PHPackages © 2026

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