smoked/filter-manager-bundle
Composer 安装命令:
composer require smoked/filter-manager-bundle
包简介
Filter manager bundle for product lists (symfony flex version)
README 文档
README
Filter manager is used for listing documents. It provides ties between commonly used filtering options and UI elements with Elasticsearch repositories. It is important to mention that filtering is everything what has impact on list, it can be:
- Filtering on specific field value object have (color, country etc.)
- Filtering range (price range, distance from point etc.)
- Documents list pagination. Paging changes representation of list, so it is considered to be filter and is treated like one.
- Documents list sorting. Same as paging - sorting is filter in this bundle.
- Any custom factor which has influence (not always directly visible) on result list. It can exclude, boost, modify some results, collect some metrics or any other action you can imagine.
If you need any help, stack overflow is the preffered and recommended way to ask ONGR support questions.
Documentation
For online documentation of the bundle click here. All docs pages are located in Resources/doc/.
Installation
Step 1: Install FilterManager bundle
FilterManager bundle is installed using Composer.
# You can require any version you need, check the latest stable to make sure you are using the newest version. $ composer require ongr/filter-manager-bundle "~2.0"
Please note that filter manager requires Elasticsearch bundle, guide on how to install and configure it can be found here.
Step 2: Enable FilterManager bundle
Enable Filter Manager bundle in your AppKernel:
// app/AppKernel.php public function registerBundles() { $bundles = [ // ... new ONGR\ElasticsearchBundle\ONGRElasticsearchBundle(), new ONGR\FilterManagerBundle\ONGRFilterManagerBundle(), new \JMS\SerializerBundle\JMSSerializerBundle(), ]; // ... }
Step 3: Add configuration for manager
Add minimal configuration for Elasticsearch and FilterManager bundles.
# app/config/config.yml ongr_elasticsearch: managers: default: index: hosts: - 127.0.0.1:9200 index_name: products ongr_filter_manager: managers: search_list: # <- Filter manager name filters: - country repository: es.manager.default.product # <- Product document repository service to execute queries on filters: country: # <- Filter name type: choice request_field: country document_field: country
Note that
Productdocument has to be defined. More about that in ElasticsearchBundle documentation.
In this particular example, we defined a single filter manager named search_list to filter documents from product repository, and we will be using the filter named country to filter on countries defined in document.
Step 4: Use your new bundle
FilterManagerBundle is ready to use. When you define filter manager the bundle generates a service according manager name. In this particular case it will be ongr_filter_manager.manager.search_list.
To get a list grab the service and call handleRequest(). Here's a short example in the controller:
<?php use ONGR\FilterManagerBundle\DependencyInjection\ONGRFilterManagerExtension; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; class ProductController extends Controller { /** * @param Request $request Request. * * @return Response */ public function listAction(Request $request) { $searchList = $this->get(ONGRFilterManagerExtension::getFilterManagerId('search_list')) ->handleRequest($request); $this->render( 'AppBundle:Product:list.html.twig', [ 'filters' => $searchList->getFilters(), 'products' => $searchList->getResult(), ] ); } }
More information how to use filters and render the results are in basics topic here.
Troubleshooting
If you face any issue or difficulty by implementing bundle, do not be afraid to create an issue with bug or question. Also ONGR organization has a tag in Stackoverflow so you can ask about all ONGR bundles also there.
License
This bundle is covered by the MIT license. Please see the complete license in the bundle LICENSE file.
smoked/filter-manager-bundle 适用场景与选型建议
smoked/filter-manager-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.2k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 05 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 smoked/filter-manager-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 smoked/filter-manager-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2.2k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-05-07