How can I share the 'common' directory with other yii application?

Hi.

I have a project in yii-advanced template. There are a lot of models in the ‘common’ directory.

I would like to share this common direcotry with other yii projects which use the yii-basci templates.

Is it possible somehow?

The yii-advanced project is a manager application. The yii-basic is just show data from database (and these data of database are managed by the yii-advanced application)

In the application config (web.php) of your basic application, you can define a path alias for your common directory. For example:




<?php


$params = require(__DIR__ . '/params.php');

Yii::setAlias('@common', dirname(__DIR__) . '../../app-advanced/common');


$config = [

    'id' => 'diary',

    'basePath' => dirname(__DIR__),

    'language' => 'ja-JP',

    'bootstrap' => [

        'log',

        'session',

    ],

    'components' => [

        'request' => [

            'cookieValidationKey' => '0123456789abcdefghijk',

        ],

        ...



And you can refer to a model in the common directory as




use common\models\SomeModel;

...

$model = new SomeModel();



This is awesome :) Thank you very much.