-1

我正在构建一个文件夹结构和全局配置,以允许我在 Yii 框架上创建应用程序,所有应用程序都可以共享通用代码、扩展或模块。

这个想法是,每个应用程序都将具有该应用程序的业务级别,但是,可以在应用程序之间共享的所有内容,我们都希望用作公共存储库(模型、扩展、小部件等)

例如,我们想共享Auth扩展来控制系统权限,但我想在公共文件夹下“安装”Auth,而不是在每个应用程序下。

下面是我要构建的架构:

应用程序的架构

我发现YiiBoilerplate是类似的东西,但他们没有按照我们想要的方式配置 Yii。

文件夹结构的愿望是:

common/
    css/
    images/
    protected/
        commands/ 
        components/ 
        config/ 
        controllers/ 
        extensions/ 
        models/ 
        views/ 
Application1/
    css/
    images/
    protected/
        commands/ 
        components/ 
        config/ 
        controllers/ 
        extensions/ 
        models/ 
        views/ 

所以,让我们来谈谈几点:

  1. 如果我的用户在应用程序 X (www.applicationx.com) 下并且登录页面是一个“常见”结构,我想向用户显示如下内容:www.applicationx.com/index.php?r=user/login .

  2. 我希望能够轻松地在应用程序文件夹和公共文件夹之间“导航”。

  3. 我不想使用主题,因为我有不同的应用程序具有不同的视觉要求和行为。

对此有什么想法吗?有什么好的建议吗?提前致谢!

4

1 回答 1

1

Well, I found some way of how to do it.

First of all, my folders structure, looks similar as it:

common/
    css/
    images/
    js/
    extensions/
        bootstrap/
        auth/
    protected/
        /* Yii Default directory folder*/
Application1/
    css/
    images/
    js/
    protected/
        /* Yii Default directory folder*/

Config File Under Common Folder

return array(
    'import'=>array(
        'common.components.*',
        'common.models.*',
    ),
    'modules' => array(
        'auth',
    ),
    'components' => array(
        'authManager' => array(
            'behaviors' => array(
                'auth' => array(
                    'class' => 'common.modules.auth.components.AuthBehavior',
                    'admins'=>array('admin', 'foo', 'bar'), 
                ),
            ),
        ),
        'user' => array(
            'class' => 'common.modules.auth.components.AuthWebUser',
        ),
        'bootstrap'=>array(
            'class'=>'common2.extensions.bootstrap.components.Bootstrap',
        ),
    ),
);

Login

The login is under 'common', so, to redirect to the login page, I just call the SiteController.php and I implented there the login process, giving for the user the ability to select the application that he wants to get in.

After the login, I redirect the user to the application address:

$this->redirect(Yii::app()->request->getBaseUrl(true) . "/../" .$App. "/" . "");

Config File Under Application Folder

under the application, the index.php file has the alias for the common directory, is the way that they can still 'talking'.

Yii::setPathOfAlias('common', dirname(__FILE__) . $directory);

If you want to do something similar and are finding hard to understand, let me know, I will put here more information, if you need to.

于 2013-06-06T04:37:04.250 回答