iblank/laravel-gov-search
Composer 安装命令:
composer require iblank/laravel-gov-search
包简介
This Laravel package integrates the USA Gov Search API. Use the config file to add your API token and affiliate.
README 文档
README
Laravel PHP Facade/Wrapper for the USA.gov, DigitalGov Search API. You will need to create an account with DigialGov to create an affiliate id and access token key: http://search.digitalgov.gov/
Installation
-
Add project to the require array in your
composer.jsonfile:"require": { "iblank/laravel-gov-search": "dev-master" } -
Run
composer updateto pull down the latest version of the package. -
Open
app/config/app.php* and add the service provider to yourprovidersarray:'providers' => array( 'iblank\GovSearch\GovSearchServiceProvider' )
* NOTE: if you are using environmental configurations, make sure to place the service provider in the app.php file respective to your environment.
Configuration
For Laravel 5
Run php artisan vendor:publish and set your API key and affiliate id in the file:
/app/config/govsearch.php
For Laravel 4
Run php artisan config:publish iblank/laravel-gov-search and set your API key and affiliate id in the file:
/app/config/packages/iblank/laravel-gov-search/config.php
Default Options
Optionally change the default values for search requests using the DEFAULTS array in the config file:
'DEFAULTS' => array( 'highlight' => true, 'limit' => 20, // 1 to 999 'sort' => 'relevance' // or 'date' )
Usage
/** * Returns PHP object of search results * @param $search (string) - what to search for * @param $options (array) - set an 'offset' index and/or override any of the defaults set in the config file * @return (object) - PHP object (details below) */ $apiResult = GovSearch::search($search, $options);
Sample Format of Returned Object:
{ "total": 356, "next_offset": 20, "spelling_correction": null, "results": [ { "title": "sample title", "url": "http://www.anyplace.com", "snippet": "sample snippet", "publication_date": "2014-11-24" } ] }
Basic Search Pagination Example
// Set Defaults $search = 'Medal of Honor'; $options = array( 'offset' => 0, 'limit' => 25 ); // Make initial call $apiResult = GovSearch::search($search, $options); // Set total results $totalResults = $apiResult['total']; // Set total pages $totalPages = ceil($totalResults / $options['limit']); // Using this example, with 77 total results, would give you 4 pages // If you want to go to page 3 of 4... $page = 3; $options['offset'] = ($page - 1) * $options['limit']; $apiResults = GovSearch::search($search, $options);
Credits
Built on code from Alaouy's Youtube Laravel Facade/Wrapper.
iblank/laravel-gov-search 适用场景与选型建议
iblank/laravel-gov-search 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 38 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 04 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「search」 「laravel」 「government」 「iblank」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 iblank/laravel-gov-search 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 iblank/laravel-gov-search 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 iblank/laravel-gov-search 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
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
A PSR-7 compatible library for making CRUD API endpoints
Pimcore 10.x Website Indexer (powered by Zend Search Lucene)
Symfony bundle for Elasticsearch integration with round-robin load balancing
统计信息
- 总下载量: 38
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-04-14