承接 m-adamski/symfony-fetch-table 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

m-adamski/symfony-fetch-table

Composer 安装命令:

composer require m-adamski/symfony-fetch-table

包简介

The Symfony bundle for interaction with the JS Fetch Table library

README 文档

README

The Symfony bundle that integrates the lightweight Fetch Table JS library to handle remote data fetching and render responsive, accessible HTML tables.

Installation

This bundle is available on Packagist and can be installed using Composer:

composer require m-adamski/symfony-fetch-table

How to use it?

The library is designed to run within controller logic. It automatically generates configuration for the JS library and handles incoming HTTP requests.

public function __construct(
    private readonly FetchTableFactory $fetchTableFactory,
) {}

#[Route("/", name: "index", methods: ["GET"])]
public function index(Request $request): Response {
    $table = $this->fetchTableFactory
            ->create("#fetch-table", [
                "ajaxURL"    => $this->generateUrl("index"),
                "ajaxMethod" => "GET",
                "components" => [
                    "search"     => [
                        "active" => true,
                    ],
                    "pagination" => [
                        "active"   => true,
                    ]
                ]
            ])
            ->addColumn("title", TextColumn::class, [
                "label" => "Title",
                "searchable" => true,
                "sortable" => true
            ])
            ->addColumn("description", TextColumn::class, [
                "label" => "Description",
                "searchable" => true,
                "sortable" => true
            ])
            ->addColumn("author", PropertyColumn::class, [
                "label"    => "Author",
                "property" => "author",
                "sortable" => true
            ])
            ->addColumn("createdAt", DateTimeColumn::class, [
                "label"  => "Creation Date",
                "format" => "d.m.Y H:i",
                "sortable" => true
            ])
            ->addColumn("options", TwigColumn::class, [
                "label"    => "Options",
                "mapped"   => false,
                "expanded" => true,
                "template" => "column/options.html.twig",
            ])
            ->createAdapter(RepositoryAdapter::class, [
                "entity"       => Book::class,
                "queryBuilder" => function (BookRepository $bookRepository) {
                    return $bookRepository->createQueryBuilder("book");
                }
            ]);

    if (null !== ($tableResponse = $table->handleRequest($request))) {
        return $tableResponse;
    }

    return $this->render("index.html.twig", [
        "table" => $table,
    ]);
}

Documentation

Detailed documentation of the JS library can be found at https://github.com/m-adamski/fetch-table.

Columns Configuration

The bundle provides a set of column types that can be used to process and render different types of data.

All columns accept basic configuration parameters:

  • type (string, default: "text") - Column type
  • label (string, required) - Column label
  • className (string, optional) - CSS class name of the column
  • sortable (boolean, default: false) - Whether the column should be sortable
  • searchable (boolean, default: false) - Whether the column should be searchable
  • mapped (boolean, default: true) - Whether the column should be mapped to the data source

TextColumn::class

Example:

->addColumn("title", TextColumn::class, [
    "label" => "Title",
    "searchable" => true,
    "sortable" => true
])

The column has no additional configuration parameters.

PropertyColumn::class

Example:

->addColumn("author", PropertyColumn::class, [
    "label"    => "Author",
    "property" => "author",
    "sortable" => true
])
  • property (string, required) - Property name of the entity
  • defaultValue (string | int | float, default: "") - Default value if property is null or undefined
  • expanded (boolean, default: true) - Whether the column value should be expanded

DateTimeColumn::class

Example:

->addColumn("createdAt", DateTimeColumn::class, [
    "label"  => "Creation Date",
    "format" => "d/m/Y H:i",
    "sortable" => true
])
  • format (string, default: "Y-m-d H:i:s") - Date format

CallableColumn::class

Example:

->addColumn("description", CallableColumn::class, [
    "label"      => "Email Address",
    "callable"   => function (string $description) {
        return "Description: $description";
    },
    "searchable" => true,
    "sortable"   => true
])
->addColumn("description", CallableColumn::class, [
    "label"      => "Email Address",
    "callable"   => function (Book $book) {
        return "Description: " . $book->getDescription();
    },
    "expanded"   => true,
    "searchable" => true,
    "sortable"   => true
])
  • callable (callable, required) - Callable that accepts the column value and returns the rendered value
  • expanded (boolean, default: false) - Whether the column value should be expanded

Adapters Configuration

The bundle provides a set of adapters that can be used to fetch data from different sources.

ArrayAdapter::class

The adapter expects a table of data as a configuration parameter and handles all search, sorting, and pagination functionality internally.

Example:

->createAdapter(ArrayAdapter::class, [
    "data" => [
        ["name" => "John Doe", "emailAddress" => "test@example.com"],
        ["name" => "Jane Smith", "emailAddress" => "jane.smith@example.com"],
        ["name" => "Michael Brown", "emailAddress" => "michael.brown@example.com"],
        ["name" => "Emily Davis", "emailAddress" => "emily.davis@example.com"],
        ["name" => "David Wilson", "emailAddress" => "david.wilson@example.com"],
        ["name" => "Sarah Johnson", "emailAddress" => "sarah.johnson@example.com"],
    ]
]);
  • data (array, required) - Array of data

CallableAdapter::class

The only configuration parameter for this adapter is a function that will be called when the data is rendered. We must provide support for searching, sorting, and pagination within this function.

Example:

->createAdapter(CallableAdapter::class, [
    "callable" => function (Query $query, $transformer, $columns, $config) {

        // Searching
        if (null !== ($searchContent = $query->getSearch())) {
            // ...
        }

        // Sorting
        if (null !== ($sort = $query->getSort())) {
            // ...
        }

        // Pagination
        if (null !== ($pagination = $query->getPagination())) {
            // ...
        }

        return (new Result())->setData(
            $transformer->transform([
                ["title" => "Title 1", "author" => "Author 1", "createdAt" => new \DateTime()],
                ["title" => "Title 2", "author" => "Author 2", "createdAt" => new \DateTime()],
            ], $columns)
        );
    }
]);
  • callable (callable, required) - Callable that accepts the query, transformer, columns, and config and returns the result

RepositoryAdapter::class

To use this adapter, you need to install the symfony/orm-pack package. The adapter handles search, sorting, and pagination functionality internally.

Example:

->createAdapter(RepositoryAdapter::class, [
    "entity"       => Book::class,
    "queryBuilder" => function (BookRepository $bookRepository) {
        return $bookRepository->createQueryBuilder("book");
    }
]);
  • entity (string, required) - Entity class name
  • queryBuilder (callable, required) - Callable that accepts the entity repository and returns the query builder (if there is a need to bypass the internal functionality of the adapter (search, sorting, and pagination), the function can return the result immediately)

License

This project is open source and available for personal and commercial use under the MIT License.

m-adamski/symfony-fetch-table 适用场景与选型建议

m-adamski/symfony-fetch-table 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 10 月 05 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 m-adamski/symfony-fetch-table 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 m-adamski/symfony-fetch-table 我们能提供哪些服务?
定制开发 / 二次开发

基于 m-adamski/symfony-fetch-table 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 13
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-05