How to reuse code for multiple domains?

I just create a CMS structure using the Yii framework. I want to deploy CMS for several domains.

/home/root/www/domain1.com
/home/root/www/domain2.com
/home/root/www/domain3.com
/home/root/www/domain4.com

I want to reuse css files and all files in a protected folder, so as soon as I update css and files in a protected folder, all domains should reflect this change.

+3
source share
1 answer

Yes, Yii supports this. In fact, that’s how I set up some websites.

(Of course, this is due to the fact that all your sites are on the same server. But I see that Evan has this. This does not work on all servers.)

-, . . .

-,, Yii AssetsBase. . . ( ). , :

/Controller.php :

    /**
     * @var registers which js, css, images have been published
     * See: http://www.yiiframework.com/wiki/311/assetmanager-clearing-browser-s-cache-on-site-          update/
 */

    private $_assetsBase;

    public function getAssetsBase()
    {
            if ($this->_assetsBase === null) {
                Yii::app()->assetManager->newDirMode = 0755;        
                Yii::app()->assetManager->newFileMode = 0644;        

                    $this->_assetsBase = Yii::app()->assetManager->publish(
                            Yii::getPathOfAlias('application.assets'),
                            false,
                            -1,
                            defined('YII_DEBUG') && YII_DEBUG
                    );
            }
            return $this->_assetsBase;
    }

, JS, CSS :

protected/assets/js/mobiscroll-2.3.custom.min.js
protected/assets/css/mobiscroll-2.3.custom.min.css
protected/assets/img/einstein.png

:

<?php
$cs->registerScriptFile($this->assetsBase.'/js/mobiscroll-2.3.1/js/mobiscroll-2.3.custom.min.js');
$cs->registerCssFile($this->assetsBase.'/js/mobiscroll-2.3.1/css/mobiscroll-2.3.custom.min.css');
?>

<img src="<?php echo $this->assetsBase ?>/img/einstein.png">

, JS CSS . , () . Yii () . JS CSS . - :

$command = 'touch /path/to/your/website/protected/assets';
exec ( $command.' 2>&1',  $output , $result  );
if ($result === 0) {
    $message = 'Assets have been pointed; a new directory should now be hashed';
} else {
    $message = 'Looks like something went wrong. Assets not pointed?';
} // END if
+3

All Articles