use yii\helpers\Url;
use yii\helpers\FileHelper;
public function afterAction($action, $result)
{$route = $action->controller->actionParams;
array_unshift($route, $action->controller->id . '/' . $action->id);
$path = Url::to($route); // '/index/index/104.html'
if(substr($path, 0, 1) === '/'){
$path = substr($path, 1); // 'index/index/104.html'
}
FileHelper::createDirectory(dirname($path)); // 创建目录
file_put_contents($path, $result); // 写入文件
return parent::afterAction($action, $result); // TODO: Change the autogenerated stub
}