hafizhfadh/laravel-simple-datatable
Composer 安装命令:
composer require hafizhfadh/laravel-simple-datatable
包简介
A Laravel-native datatable engine providing both server-side and client-side processing modes.
README 文档
README
Laravel Simple Datatable is a lightweight, framework-native engine designed to bridge Laravel with simple-datatables (and similar frontend libraries). It provides a fluent, secure, and pipeline-driven approach to handling server-side and client-side data processing without the bloat of jQuery or heavy dependencies.
Built with TailwindCSS v4 compatibility in mind and engineered for Laravel 11.x & 12.x, this package offers enterprise-grade performance with a developer-friendly API.
🚀 Key Features
- Dual Processing Modes: Seamlessly switch between Server-side (Eloquent Builder) and Client-side (Collection) modes.
- Pipeline-Driven Architecture: Modular execution flow using Laravel's pipeline pattern for Search, Sort, and Pagination stages.
- Secure by Default: Explicit column whitelisting, strict sort direction validation, and parameterized queries to prevent SQL injection.
- Fluent API: Define columns and configuration using a clean, chainable syntax.
- No Frontend Dependencies: Pure PHP backend logic that outputs standard JSON, giving you complete freedom over your frontend stack.
- PHP 8.3+ & Strict Typing: Leveraging the latest PHP features for reliability and performance.
📦 Installation
You can install the package via composer:
composer require hafizhfadh/laravel-simple-datatable
🔧 Usage
1. Basic Setup
The simplest way to use the datatable is by passing an Eloquent query or a Collection to the make method.
Server-Side (Recommended for Large Datasets)
use HafizhFadh\LaravelSimpleDatatable\Facades\SimpleDatatable; use HafizhFadh\LaravelSimpleDatatable\Support\Column; use App\Models\User; public function index() { // Automatically detects Builder and enables Server Mode return SimpleDatatable::make(User::query()) ->columns([ Column::make('name')->searchable()->sortable(), Column::make('email')->searchable(), Column::make('created_at')->sortable(), ]) ->process(); }
Client-Side (Fallback for Small Datasets)
use HafizhFadh\LaravelSimpleDatatable\Facades\SimpleDatatable; use HafizhFadh\LaravelSimpleDatatable\Support\Column; public function index() { $users = User::all(); // Returns a Collection // Automatically detects Collection and enables Client Mode return SimpleDatatable::make($users) ->columns([ Column::make('name')->searchable()->sortable(), Column::make('email')->searchable(), ]) ->process(); }
2. Column Configuration
Columns must be explicitly defined to enable interaction. This is a security feature to prevent arbitrary sorting or searching on sensitive fields.
Column::make('username') ->searchable() // Allows filtering by this column ->sortable(); // Allows sorting by this column
3. Frontend Integration
This package outputs a JSON response compatible with most datatable libraries. Here is an example response structure:
Server Mode Response:
{
"data": [...],
"meta": {
"current_page": 1,
"per_page": 10,
"last_page": 5,
"total": 42
}
}
Client Mode Response:
{
"data": [...],
"meta": {
"mode": "client",
"total": 42
}
}
🎨 Frontend Integration
For a comprehensive guide on integrating this package with simple-datatables and styling it with TailwindCSS v4, please refer to our Frontend Integration Guide.
⚙️ Advanced Configuration
Manual Mode Selection
You can force a specific mode if needed:
SimpleDatatable::make(User::query()) ->clientSide() // Force fetching all data and processing in memory ->process();
Request Injection
By default, the engine uses the current global request. You can inject a custom request instance:
SimpleDatatable::make($query) ->request($customRequest) ->process();
🧪 Testing
We use Pest for testing. To run the test suite:
composer test
🤝 Contributing
Contributions are welcome! Please see CONTRIBUTING.md for details.
- Fork the repository.
- Create a new feature branch.
- Commit your changes.
- Push to the branch.
- Open a Pull Request.
🔒 Security
If you discover any security related issues, please email info@hafizhfadh.id instead of using the issue tracker.
📄 License
The MIT License (MIT). Please see License File for more information.
HafizhFadh/LaravelSimpleDatatable — Simple, Secure, Scalable.
hafizhfadh/laravel-simple-datatable 适用场景与选型建议
hafizhfadh/laravel-simple-datatable 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「datatable」 「tailwindcss」 「simple-datatables」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 hafizhfadh/laravel-simple-datatable 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 hafizhfadh/laravel-simple-datatable 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 hafizhfadh/laravel-simple-datatable 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
DataTables is a plug-in for the jQuery Javascript library. It is a highly flexible tool, based upon the foundations of progressive enhancement, which will add advanced interaction controls to any HTML table.
TitleWithSlugInput - Easy Permalink Slugs for the FilamentPHP Form Builder (PHP / Laravel / Livewire)
Plug-ins for DataTables
TailwindPHP - use Tailwind CSS in your PHP projects (without npm)
Vanilla Components Integration with Laravel
Data Table will allow you to easily create Listing, Searching, Sorting and Download CSV.
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 27
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-27