strawberrydev/siftify 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

strawberrydev/siftify

最新稳定版本:v1.0.3

Composer 安装命令:

composer require strawberrydev/siftify

包简介

Laravel package for managing HTTP request filtering.

README 文档

README

Latest Version on Packagist

Siftify is a Laravel package designed for building robust APIs with ease. It provides a flexible and intuitive API for filtering, sorting, and paginating Eloquent models—ideal for developers who want powerful query capabilities with minimal effort.

Installation

To install Siftify, run the following composer command:

composer require strawberrydev/siftify

Publish Configuration

Publish the package's configuration file by running:

php artisan vendor:publish --tag="siftify-config"

This will generate the configuration file in config/siftify.php.

Basic Usage

Here's an example of how to use Siftify in your controller:

use strawberrydev\Siftify\Siftify;

class UserController extends Controller
{
    public function index(Request $request)
    {
        // Create a new Siftify instance
        $siftify = Siftify::for($request)
            ->filterOnModel(User::class)
            ->allowedFilters('name', 'email', 'role', 'created_at')
            ->relationships('posts', 'profile')
            ->paginate()
            ->get();
        
        // Return the filtered, sorted, and paginated results
        return $siftify->toJson();
    }
}

Making Requests

You can now make API requests like:

GET /api/users?name=John&role=admin&sort=created_at&order=desc&page=2&per_page=15

Filtering Relations

You can also filter based on related models. For example:

GET /api/users?posts.title=Laravel&profile.country=US

Or use alternate syntax:

GET /api/users?posts*title=Laravel&profile*country=US

Quick Start

For more detailed documentation, examples, and advanced usage, check out the Quick Start Guide.

Configuration Options

The configuration file config/siftify.php provides options to customize:

  • Pagination settings
  • Response format
  • Meta information
  • Security settings
  • Standard parameters

Contributing

We welcome contributions! Feel free to suggest improvements or submit PRs.

Security

If you find any security-related issues, please get in touch directly.

License

This project is licensed under the MIT License.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: AGPL-3.0-or-later
  • 更新时间: 2025-04-07