1.方法
文件上传
// request继承AbstractController得到
$request = $this->request;
$file = $request->file('file');
$file =$request->file($key);
// $path目录必须存在
$path = 'public/aliyun/'.time().mt_rand(1,10000).'.'.$file->getExtension();
$file->moveTo($path);
日志记录
$log = \Hyperf\Utils\ApplicationContext::getContainer()->get(\Hyperf\Logger\LoggerFactory::class)->get($name,'default');
$log->info($data);
2.注意事项
对象只能存储到数组,不能对象存储对象
数组a存储10个对象a,每个对象a里面存储一个对象b。循环数组打印对象a里面的对象b,所有的数据都是最后一个对象b。