【发布时间】:2021-06-20 16:34:31
【问题描述】:
我想在命令行中运行 php 脚本。我已将此文件创建到根文件夹中。并且只想运行一次。
二进制.php
global $em;
$binaryContentRepository = $em->getRepository('\xxx\Entity\xxxx');
$datas = $binaryContentRepository->getAllAttechment();
foreach($datas as $data){
$ext = pathinfo($data['filename'], PATHINFO_EXTENSION);
file_put_contents("C:\\xxxxxx\\".$data['id'].".".$ext, $data['content']);
}
我已尝试运行此文件php -f binary.php。但无法运行成功。
【问题讨论】:
-
你有什么错误吗?
-
是的。致命错误:在 null 上调用成员函数 getRepository()
-
$em;设置在哪里?
标签: php shell symfony cmd command