stanislav-web/phalcon-searcher
Composer 安装命令:
composer require stanislav-web/phalcon-searcher
包简介
Phalcon Database Searcher. This is the search service is designed to search multiple SQL tables. Convenient to use autocomplete, search documents, search the whole site.
README 文档
README
Extension is used to group search for project models. (Currently under TDD)
Description
This is the search service is designed to search multiple SQL tables. Convenient to use autocomplete, search documents, search the whole site.
Change Log
[v 1.0-beta] 2014-12-16
- support MySQL
- support column type such as INT, VARCHAR, CHAR, TEXT, DATE, DATETIME
- fulltext search
- support all main expressions (where, order, group, limit, offset)
- multi table search
- compatible with \Phalcon\Paginator
- view results as json, serialized, array or \Phalcon\Mvc\Model\Resultset\Simple
- support callbacks to pretty modifying result
Compatible
- PSR-0, PSR-1, PSR-2, PSR-4 Standards
System requirements
- PHP 5.5.x >
- MySQL
- Phalcon extension 1.3.x
Install
First update your dependencies through composer. Add to your composer.json:
"require": { "stanislav-web/phalcon-searcher": "dev-master", }
Then run to update dependency and autoloader
php composer.phar update php composer.phar install
or just
php composer.phar require stanislav-web/phalcon-searcher dev-master
(Do not forget to include the composer autoloader)
Or manual require in your loader service
$loader->registerNamespaces([ 'Searcher\Searcher' => 'path to src' ]);
You can create an injectable service
$this->di['searcher'] = function() { return new \Searcher\Searcher(); };
Usage
Simple usage
<?php use \Searcher\Searcher; // create object instance $searcher = new Searcher(); // Prepare models and fields to participate in search $searcher->setFields([ '\Models\Auto' => [ 'mark', 'model' ], '\Models\Distributor' => [ 'name', 'description' ] ]) ->setQuery('FerRari'); $result = $searcher->run();
Filters
<?php use \Searcher\Searcher; // create object instance $searcher = new Searcher(); // Prepare models and fields to participate in search $searcher->setFields([ '\Models\Auto' => [ 'mark', 'model' ], '\Models\Distributor' => [ 'name', 'description' ] ]) ->setMin(3) // minimum char to query ->setMax(15) // maximum char to query ->setExact(true) // strict mode search ->setOrder(['\Models\Auto' => ['id' => 'DESC']]) // ORDER BY \Models\Auto.id DESC ->setGroup(['\Models\Distributor' => ['id']]) // GROUP BY \Models\Auto.id ->setThreshold(100) // LIMIT 100 ->setQuery('FerRari'); $result = $searcher->run();
<?php use \Searcher\Searcher; // create object instance $searcher = new Searcher(); // Prepare models and fields to participate in search $searcher->setFields([ '\Models\Auto' => [ 'mark', 'model' ], '\Models\Distributor' => [ 'name', 'description' ] ]) ->setExact(true) // strict mode search ->setOrder([ '\Models\Auto' => ['id' => 'DESC'] '\Models\Distributor' => ['description' => 'ASC'] ]) // ORDER BY \Models\Auto.id DESC, \Models\Distributor.description ASC ->setGroup([ '\Models\Auto' => ['id', 'mark'] '\Models\Distributor' => ['id', 'description'] ]) // GROUP BY \Models\Auto.id, \Models\Auto.mark, \Models\Distributor.id, \Models\Distributor.description ->setThreshold([0,100]) // OFFSET 0, LIMIT 100 ->setQuery('FerRari'); $result = $searcher->run();
Result modifiers and callbacks
<?php use \Searcher\Searcher; // create object instance $searcher = new Searcher(); // Prepare models and fields to participate in search $searcher->setFields([ '\Models\Auto' => [ 'mark', 'model' ], '\Models\Distributor' => [ 'name', 'description' ] ]) ->setQuery('FerRari'); $result = $searcher->run('json'); // available array, serialize, json, Resultset as default // OR /** * @param $result */ $result = $searcher->run('array', function($result) { //... any modifiers return $result; }); // available, array, serialize, json, Resultset as default
Unit Test
Also available in /phpunit directory. Run command to start
php build/phpunit.phar --configuration phpunit.xml.dist --coverage-text
Read logs from phpunit/log
##Issues
Screen (For what I use it?)
stanislav-web/phalcon-searcher 适用场景与选型建议
stanislav-web/phalcon-searcher 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 397 次下载、GitHub Stars 达 25, 最近一次更新时间为 2014 年 12 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「phalcon」 「phalcon search」 「phalcon searcher」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 stanislav-web/phalcon-searcher 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 stanislav-web/phalcon-searcher 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 stanislav-web/phalcon-searcher 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Searcher is a framework-agnostic search query builder. Search queries are written using Criterias and can be run against MySQL, MongoDB, ElasticSearch or even files.
A Laravel package to retrieve data from Google Search Console
Indexed Search Autocomplete - Extends the TYPO3 Core Extension Indexed_Search searchform with an autocomplete feature.
Abstraction Layer to index and search entities
Laravel SDK for searching data in DB using requests
Uniondrug Trace Client Component for uniondrug/framework
统计信息
- 总下载量: 397
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 26
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 5
其他信息
- 授权协议: MIT
- 更新时间: 2014-12-03