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 :
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