小编dem*_*vil的帖子

如何使用 Symfony 的 StreamedResponse 导出 CSV?

我的代码看起来不错,我得到状态 200,我得到正确的标题,...但我创建的 CSV 文件无法下载...

\n

没有错误,所以我不明白为什么会失败。

\n

这是我的代码:

\n
namespace Rac\\CaraBundle\\Manager;\n\n/* Imports */\nuse Symfony\\Component\\PropertyAccess\\PropertyAccess;\nuse Symfony\\Component\\Validator\\ValidatorInterface;\nuse Symfony\\Component\\EventDispatcher\\EventDispatcherInterface;\nuse Doctrine\\Common\\Persistence\\ObjectManager;\nuse Symfony\\Component\\HttpFoundation\\StreamedResponse;\n\n/* Local Imports */\nuse Rac\\CaraBundle\\Entity\\Contact;\n\n/**\n * Class CSV Contact Importer\n */\nclass CSVContactImporterManager {\n\n    /**\n     * @var ObjectManager\n     */\n    private $om;\n\n    /**\n     * @var EventDispatcherInterface\n     */\n    private $eventDispatcher;\n\n    /**\n     * @var ValidatorInterface\n     */\n    private $validator;\n\n    /**\n     * @var ContactManager\n     */\n    private $contactManager;\n\n\n    /**\n     * @param EventDispatcherInterface $eventDispatcher\n     * @param ObjectManager            $om\n     * @param Contact                  $contactManager\n     *\n     */\n    public function __construct(\n    EventDispatcherInterface $eventDispatcher, ObjectManager $om, …
Run Code Online (Sandbox Code Playgroud)

php csv symfony symfony-http-foundation

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

csv ×1

php ×1

symfony ×1

symfony-http-foundation ×1