public function actionCreate_product_list() { //\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; $product_all_list = Product::get_all_product(); $response = []; $response['product_list'] = $product_all_list; $fp = fopen('json/project_list.json', 'w'); fwrite($fp, \yii\helpers\Json::encode($response)); fclose($fp); return $this->redirect(['/']); }