alpixel/elastica-query-sorter-bundle
Composer 安装命令:
composer require alpixel/elastica-query-sorter-bundle
包简介
Pagination and sort for elastica
README 文档
README
Installation
Install the bundle from composer
$ composer require alpixel/elastica-query-sorter-bundle
Enable the bundle in your AppKernel.php
<?php use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Config\Loader\LoaderInterface; class AppKernel extends Kernel { public function registerBundles() { $bundles = [ new Alpixel\Bundle\ElasticaQuerySorterBundle\AlpixelElasticaQuerySorterBundle(), ] } }
Configuration
Add minimal configuration in your config.yml
alpixel_elastica_query_sorter: views:
Configuration reference
alpixel_elastica_query_sorter: views: clear_sort: # Path to your twig file, link to the current route (path(app.request.attributes.get('_route'), {'clear_sort' : true})) sort_link: # Path to your twig file, check the "Resources/views/blocks/sort_link.html.twig" for more informations item_per_page: 10 # Number of item per page, default 25
Usage
Full functional usage exemple :
First in your controller, like usualy create or use existing action of your controller.
<?php namespace AppBundle\Controller; use AppBundle\Form\MyForm; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\Form\Form; use Symfony\Component\HttpFoundation\Request; class ResearchController extends Controller { /** * @Route("/home", name="home") */ public function shopAction(Request $request) { $form = $this->createform(MyForm::class); $form->handleRequest($request); $data = $form->getData(); $repository = $this->get('fos_elastica.manager')->getRepository('AppBundle:MyEntity'); $query = $repository->queryCustom($data); // You need to pass the repository and the query from elastica (\Elastica\Query) $results = $this->get('alpixel.services.elastica_query_sorter') ->sort($repository, $query); return $this->render('page/home.html.twig', [ 'results' => $results, 'form' => $form->createView(), ]); } }
And in your view.
{% extends 'layout/base.html.twig' %}
{% block page %}
{{ form_start(form) }}
{{ form_widget(form) }}
<input type="submit" value="Rechecher">
{{ form_end(form) }}
<table>
<thead>
<tr>
// You must define your mapping in your elastica configuration
// The first parameter is the label to display on your page
// The second parameter is the mapping to you attribute, you want to sort
<th>{{elastica_sort('Name', 'name')}}</th>
// If the attribute is an object, you just need apply the good mapping to the attribute
<th>{{elastica_sort('Serial Number', 'product.serial_number')}}</th>
<th>{{elastica_sort('Date', 'date_updated')}}</th>
</tr>
</thead>
<tbody>
{% for result in results %}
<tr>
<td>{{ result.name }}</td>
<td>{{ result.product.serialNumber }}</td>
<td>{{ result.dateUpdated|date }}</td>
</tr>
{% endfor %}
</tbody>
</table>
// The pagerfanta is used for pagination, check the documentation of this bundle
{{ pagerfanta(results, 'twitter_bootstrap3_translated') }}
{% endblock %}
alpixel/elastica-query-sorter-bundle 适用场景与选型建议
alpixel/elastica-query-sorter-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.74k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2016 年 03 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「Symfony2」 「pagination」 「bundle」 「elastica」 「sort」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 alpixel/elastica-query-sorter-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 alpixel/elastica-query-sorter-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 alpixel/elastica-query-sorter-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The bundle for easy using json-rpc api on your project
Bundle Symfony DaplosBundle
Symfony2 Barcode Generator Bundle with Twig function extension
Symfony bundle to connect AWS sns and sqs to create offline queue processing
Integrate the doctrine-translatable extension in Symfony2
Video Editor Bundle
统计信息
- 总下载量: 4.74k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-03-17