PHPackages                             ovidiupop/yii2-address - 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. ovidiupop/yii2-address

ActiveYii2-extension

ovidiupop/yii2-address
======================

The address module is a Yii2 extension designed to simplify the management and integration of address-related functionalities within your Yii2 applications. It provides a seamless way to handle addresses as a standalone entity, allowing you to associate them with various models, such as customers, companies, or any other entities in your application.

091PHP

Since Jan 15Pushed 2y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

**Description**

The address module is a Yii2 extension designed to simplify the management and integration of address-related
functionalities within your Yii2 applications. It provides a seamless way to handle addresses as a standalone entity,
allowing you to associate them with various models, such as customers, companies, or any other entities in your
application.

**Installation**

The preferred method for installation is using Composer.

```
composer require ovidiupop/yii2-address "@dev"

```

Or, add the following line to your composer.json file::

```
"ovidiupop\yii2-address": "@dev"

```

**Configuration:**

1. Run the migration in the migrations folder to create the 'address' table. The model that includes the address will need a field "address\_id" that relates to the "address" table.
2. In the config/main.php file, add:

```
'modules' => [
    'address' => [
     'class' => 'ovidiupop\address\Address',
    ],
........
'controllerMap' => [
     'address'=> 'ovidiupop\address\controllers\AddressController',
 ..............

```

**Usage**

In the create and update actions of the controller being used, you can proceed as follows:

```
use ovidiupop\address\models\Address;

public function actionCreate()
{
    $model = new Model();
    $addressModel = new Address();

    if ($model->load(Yii::$app->request->post()) && $addressModel->load(Yii::$app->request->post())) {
        if ($addressModel->save()) {
            $model->address_id = $addressModel->id;
            if ($model->save()) {
                return $this->redirect(['view', 'id' => $model->id]);
            }
        }
    }

    return $this->render('create', [
        'model' => $model,
        'addressModel' => $addressModel,
    ]);
}

public function actionUpdate($id)
{
    $model = $this->findModel($id);
    $addressModel = $model->address_id ? Address::findOne($model->address_id) :  new Address();

    if ($model->load(Yii::$app->request->post()) && $addressModel->load(Yii::$app->request->post())) {
        if ($addressModel->save()) {
            $model->address_id = $addressModel->id;
            if ($model->save()) {
                return $this->redirect(['view', 'id' => $model->id]);
            }
        }
    }

    return $this->render('update', [
        'model' => $model,
        'addressModel' => $addressModel,
    ]);
}

```

In the host model's form, add one of the predefined form variants for displaying the address fields:

- If you want to display the inputs horizontally (default mode):

    ```

    ```
- If you want to display the inputs in a vertical column:

    ```

    ```
- If you want to display the inputs in 2 vertical columns:

    ```

    ```
- If you want a custom form, you can either copy one of the existing three and adjust it according to your preferences,
    or create a completely new one. To use it, add the paths to the custom form or forms in the configuration as follows:

    'modules'=&gt;\[ 'address' =&gt; \[ 'class' =&gt; 'ovidiupop\\address\\AddressModule', 'formCustom' =&gt; '@path/to/views/my\_custom\_form', \],

In this case, the address form will be displayed in the form with:

```

```

**i18n**

For message translation, the 'address' convention \[Yii::t('address', message)\] has been used as the "category."

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity19

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/8bb4a24c5644cb321360d37f46ad33c41e901f347a9b0fbe1ccaa5c6f2a4a10d?d=identicon)[ovidiupop](/maintainers/ovidiupop)

---

Top Contributors

[![ovidiupop](https://avatars.githubusercontent.com/u/1079754?v=4)](https://github.com/ovidiupop "ovidiupop (9 commits)")

### Embed Badge

![Health badge](/badges/ovidiupop-yii2-address/health.svg)

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

PHPackages © 2026

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