mrkacmaz/laravel-ssp
Composer 安装命令:
composer require mrkacmaz/laravel-ssp
包简介
Process server-side processing (SSP) for an Eloquent model, supporting dynamic filtering, sorting, and pagination.
README 文档
README
SSP-INIT is a Laravel package designed to facilitate server-side processing (SSP) for Eloquent models, supporting dynamic filtering, sorting, and pagination. This package simplifies the development of data-intensive applications by abstracting complex server-side operations.
Features
- Dynamic Filtering: Apply filters based on request parameters.
- Sorting: Sort data by any model attribute.
- Pagination: Efficiently paginate the data based on the client's request.
- Eager Loading: Supports eager loading of relationships to optimize query performance.
- Response Encoding: Optionally encode the response data.
Requirements
- PHP ^8.2
- Laravel ^8.0
Installation
To install the SSP-INIT package, run the following command in the root of your Laravel project:
composer require mrkacmaz/laravel-ssp
Usage
Here is a basic example of how to use the SSP trait in a Laravel controller:
Controller
<?php namespace App\Http\Controllers; use Mrkacmaz\LaravelSsp\Traits\SSP; use App\Models\User; use Illuminate\Http\Request; class UserController extends Controller { use SSP; public function index(Request $request) { if ($request->expectsJson()){ $data = self::processSSP($request, User::class); return response()->json($data); } return view('welcome'); } }
Blade File
<x-app-layout> <table class="table table-hover"> <thead> <tr> <th scope="col">#</th> <th scope="col">Full Name</th> <th scope="col">Email</th> </tr> </thead> <tbody></tbody> </table> </x-app-layout>
JS File
$(function (){ $('.table').DataTable({ serverSide: true, processing: true, ajax: { url: window.location, type: 'GET', dataSrc: function (data) { return JSON.parse(atob(data.data)); } }, columns: [ {data: 'id'}, {data: 'name'}, {data: 'email'}, ], }); });
In this example, the UserController utilizes the SSP trait to process data for the User model according to the parameters specified in the request.
Configuration
No additional configuration is required to start using SSP-INIT, as it uses Laravel's default configurations.
Support
If you are having issues, please let us know by submitting an issue on GitHub.
License
This project is licensed under the MIT License - see the LICENSE.md file for details.
mrkacmaz/laravel-ssp 适用场景与选型建议
mrkacmaz/laravel-ssp 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 04 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 mrkacmaz/laravel-ssp 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mrkacmaz/laravel-ssp 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-04-22