coders/phind
Composer 安装命令:
composer require coders/phind
包简介
Create, Ruin, Undo, Despair
README 文档
README
Create, Ruin, Undo, Despair
A PHP library for data abstraction and query building that provides a unified interface for working with different data sources including SQL databases, NoSQL databases, and key-value stores.
Features
- Data Source Abstraction: Support for multiple data sources (MySQL, NoSQL, Key-Value stores)
- Query Builder: Fluent interface for building complex queries
- Collection Management: Easy-to-use collection and entity management
- Filtering & Sorting: Advanced filtering and sorting capabilities
- Static Registry: Centralized management of data sources and collections
Installation
Install via Composer:
composer require coders/phind
Quick Start
Setting up a Data Source
use Coders\Phind\Sources; use Coders\Phind\Sources\SourceConfig; // Create a MySQL data source $config = new SourceConfig([ 'driver' => 'mysql', 'host' => 'localhost', 'database' => 'mydb', 'username' => 'user', 'password' => 'pass' ]); $source = Sources::create('main', $config);
Creating Collections
use Coders\Phind\Collections; // Create collections for your entities Collections::create($source, ['Users', 'Posts', 'Comments']); // Get a collection $users = Collections::get('Users');
Working with Entities
// Create a new entity $user = $users->entity(); $user->name = 'John Doe'; $user->email = 'john@example.com'; $user->age = 30; // Save the entity $users->save($user); // Retrieve entities by ID $user = $users->get('user-id-123'); $multipleUsers = $users->get(['id1', 'id2', 'id3']);
Building Queries
use Coders\Phind\Query; use Coders\Phind\Query\Filter; use Coders\Phind\Query\SortAsc; use Coders\Phind\Query\SortDesc; // Create a query $query = new Query('users'); // Add filters $query->filter(new Filter('age', 18, Filter::GTE)) ->filter(new Filter('status', 'active')); // Add sorting $query->sortBy(new SortAsc('name')) ->sortBy(new SortDesc('created_at')); // Set limit and offset $query->limit(10) ->offset(20); // Select specific fields $query->select(['id', 'name', 'email']); // Execute the query $results = $source->retrieve($query);
Advanced Filtering
use Coders\Phind\Query\AndFilters; use Coders\Phind\Query\OrFilters; // Create complex filter groups $ageFilter = new Filter('age', 18, Filter::GTE); $statusFilter = new Filter('status', ['active', 'premium'], Filter::IN); $orGroup = new OrFilters(); $orGroup->add($ageFilter)->add($statusFilter); $query->filter($orGroup);
Joining Queries
// Create related queries $postsQuery = new Query('posts'); $postsQuery->filter(new Filter('published', true)); // Join with main query $query->join($postsQuery);
Data Sources
The library supports multiple data source types:
- MySQL: SQL-based relational database
- NoSQL: Document-based databases
- Key-Value: Simple key-value stores
- Chain: Combine multiple data sources
- StaticCache: In-memory caching layer
Query Operations
- Filtering: Equal, not equal, greater than, less than, in, not in
- Sorting: Ascending and descending order
- Limiting: Pagination support with limit and offset
- Joining: Combine data from multiple collections
- Field Selection: Choose specific fields to retrieve
Requirements
- PHP 8.0 or higher
- Composer for dependency management
Development
Running Tests
./vendor/bin/phpunit tests/
Code Style
./vendor/bin/php-cs-fixer fix
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Author
Irek Kubicki - github@ixdude.com
coders/phind 适用场景与选型建议
coders/phind 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 10 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 coders/phind 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 coders/phind 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-10-19