ilbee/csv-response
最新稳定版本:1.3.0
Composer 安装命令:
composer require ilbee/csv-response
包简介
Symfony component allow you to respond CSV contents directly in your controller
README 文档
README
Add a CSV export response in your [Symfony] controller.
📖 Table of Contents
ℹ️ Prerequisites
- PHP >= 7.4
- Symfony >= 4.4
⚙ Installation
Use [Composer] to install this package:
composer require ilbee/csv-response
🛠️ How to use ?
Simply return a CSVResponse object in your Symfony controller, and you will be able to download a CSV file.
Here’s a simple example:
<?php // ./src/Controller/MyController.php namespace App\Controller; use Ilbee\CSVResponse\CSVResponse; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Routing\Annotation\Route; class MyController extends AbstractController { /** * @Route("/download-csv", name="download_csv") */ public function downloadCsv(): CSVResponse { $data = []; $data[] = [ 'firstName' => 'Marcel', 'lastName' => 'TOTO', ]; $data[] = [ 'firstName' => 'Maurice', 'lastName' => 'TATA', ]; return new CSVResponse($data); } }
Explanation
- CSVResponse: This class generates an HTTP response that will trigger a CSV file download based on the provided data.
- Data Example: You can replace the
$dataarray with your own data, fetched from a database or other sources.
🔗 Useful Links
🙏 Thanks
Special thanks to Paul Mitchum and Dan Feder for their contributions!
统计信息
- 总下载量: 147.49k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-03-26