Download the PHP package madong/query without Composer

On this page you can find all versions of the php package madong/query. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package query

Madong Query

一个强大的查询参数解析和过滤库,为 PHP 8.1+ 项目提供灵活、类型安全的查询构建能力。

✨ 特性

📦 安装

通过 Composer 安装:

环境要求

🚀 快速开始

基本使用

使用 Trait(推荐)

在 Controller 中使用:

使用门面(CLI 环境)

📖 核心概念

查询参数格式

支持多种查询参数格式:

1. 标准 filters 格式

2. 大写前缀格式

3. 数组格式

支持的操作符

操作符 说明 示例
eq 等于 ['field' => 'status', 'operator' => 'eq', 'value' => 'active']
ne 不等于 ['field' => 'status', 'operator' => 'ne', 'value' => 'deleted']
gt 大于 ['field' => 'age', 'operator' => 'gt', 'value' => 18]
gte 大于等于 ['field' => 'age', 'operator' => 'gte', 'value' => 18]
lt 小于 ['field' => 'age', 'operator' => 'lt', 'value' => 60]
lte 小于等于 ['field' => 'age', 'operator' => 'lte', 'value' => 60]
like 模糊匹配 ['field' => 'name', 'operator' => 'like', 'value' => 'John']
ilike 不区分大小写模糊匹配 ['field' => 'name', 'operator' => 'ilike', 'value' => 'john']
in 包含 ['field' => 'id', 'operator' => 'in', 'value' => [1, 2, 3]]
not_in 不包含 ['field' => 'id', 'operator' => 'not_in', 'value' => [4, 5, 6]]
between 范围 ['field' => 'price', 'operator' => 'between', 'value' => [10, 100]]
not_between 非范围 ['field' => 'price', 'operator' => 'not_between', 'value' => [10, 100]]
null 为空 ['field' => 'deleted_at', 'operator' => 'null']
not_null 不为空 ['field' => 'deleted_at', 'operator' => 'not_null']

枚举类型

Operator 枚举

QueryMode 枚举

ParamFormat 枚举

🎯 高级用法

自定义查询选项

关键词搜索

分页查询

排序

多层查询

🔧 集成方式

1. Controller 集成

2. Service 集成

3. DAO 集成

4. 依赖注入

5. SelectInput 集成(灵活参数解析)

WithSelectInput Trait 提供高度可配置的参数解析功能,适用于需要精确控制的场景。

基本使用

自定义配置

配置选项

选项 类型 默认值 说明
return_format string 'array' 返回格式:array、object、compact
param_format string 'auto' 参数格式:filters、uppercase、array、where、auto
allowed_fields array\|null null 允许的字段白名单
skip_fields array [] 跳过的字段黑名单
sort_fields array\|null null 允许排序的字段
default_sort array [] 默认排序规则
default_page_size int 10 默认每页数量
max_page_size int 100 最大每页数量
default_page int 1 默认页码
keyword_fields array [] 关键词搜索字段
enable_keyword_search bool false 是否启用关键词搜索
keyword_param string 'keyword' 关键词参数名
enable_range_query bool true 是否启用范围查询
enable_like_query bool true 是否启用模糊匹配
auto_convert_datetime bool true 是否自动转换日期时间
skip_empty_values bool true 是否跳过空值
debug_mode bool false 是否启用调试模式

在 Crud 中使用(推荐)

配置优先级:方法参数配置 > 类属性配置 > 默认配置

🛠️ 核心类

QueryParamsManager

查询参数管理器,提供统一的查询处理入口。

QueryCondition

查询条件对象,封装单个查询条件。

QueryParamParser

查询参数解析器,支持多种参数格式。

QueryBuilderHelper

查询构建器辅助类,应用查询条件到构建器。

QueryParamConverter

参数转换器,转换不同格式的参数。

QueryFacade

门面类,提供静态访问接口(适用于 CLI 环境)。

🧪 异常处理

QueryException

基础查询异常。

QueryParseException

查询参数解析异常。

📚 完整示例

用户管理接口

高级查询示例

关键词搜索示例

🎨 最佳实践

1. 使用 Trait 简化代码

2. 配置允许查询的字段

3. 设置分页限制

4. 使用关键词搜索

🔒 安全建议

  1. 限制允许查询的字段: 使用 allowed_fields 选项
  2. 设置分页上限: 使用 max_page_size 选项
  3. 验证输入数据: 对用户输入进行验证
  4. 使用参数绑定: 底层自动使用参数绑定防止 SQL 注入

📄 许可证

Apache-2.0 License

👨‍💻 作者

Mr. April - [email protected]

🌐 官方网站

http://www.madong.tech

🤝 贡献

欢迎提交 Issue 和 Pull Request!

📞 支持

如有问题,请提交 Issue 或联系作者。



All versions of query with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
illuminate/database Version ^11.0
illuminate/pagination Version ^11.0
madong/helper Version ^1.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package madong/query contains the following files

Loading the files please wait ...