定制 amark/laravelsearchengine 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

amark/laravelsearchengine

Composer 安装命令:

composer require amark/laravelsearchengine

包简介

Laravel package to get Google Custom Search results from Google Custom Search Engine API.

README 文档

README

1/ Install with Composer

composer require amark/laravelsearchengine

2/ Add the service provider to config/app.php

'providers' => [
    '...',
    AmarK\LaravelSearchEngine\LaravelSearchEngineProvider::class
];

Creating your custom search engine

  1. If you create your engine at https://cse.google.com/cse/ you will find the ID after you click at Settings
  2. Just check the URL you have like https://cse.google.com/cse/setup/basic?cx=search_engine_id and the string after cx= is your search engine ID

!! Attention !! If you change style of your Custom search engine, the ID can be changed

Get your API key

  1. go to https://console.developers.google.com, than
  2. click on the menu on the right side of the GoogleAPI logo and click on 'Create project'
  3. enter the name of the new project - it is up to you, you can use 'Google CSE'
  4. wait until project is created - the indicator is color circle on the top right corner around the bell icon
  5. API list is shown - search for 'Google Custom Search API' and click on it
  6. click on 'Enable' icone on the right side of Custom Search API headline
  7. click on the 'Credentials' on the left menu under the 'Library' section
  8. click on the 'Create credentials' and choose 'API key'
  9. your API key is shown, so copy and paste it here

Save the configuration values

Save search engine ID and api ID in your config/laravelSearchEngine.php

Usage

Create an object and call the function getResults to get first 10 results

$textresult = new LaravelSearchEngine(); // initialize
$results = $textresult->getResults('search text'); // get first 10 results for query 'search text' 
namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use AmarK\LaravelSearchEngine\LaravelSearchEngine;

class GoogleSearchController extends Controller
{

  public function index(){
    $textResult = new LaravelSearchEngine(); // initialize
    $results = $textResult->getResults('search text'); // get first 10 results for query 'search text' 
  }
}
$parameters = array(
    'start' => 10 // start from the 10th results,
    'num' => 10 // number of results to get, 10 is maximum and also default value
)

$textresult = new LaravelSearchEngine(); // initialize
$results = $textresult->getResults('search text', $parameters); // get second 10 results for query 'search text'
$textResult = new LaravelSearchEngine(); // initialize
$results = $textResult->getResults('search text'); // get first 10 results for query 'search text'
$rawResults = $textResult->getRawResults(); // get complete response from Google

For getting the number of results only use

$textResult = new LaravelSearchEngine(); // initialize
$results =  $textResult->getResults('search text'); // get first 10 results for query 'search text'
$noOfResults = $textResult->getTotalNumberOfResults(); // get total number of results (it can be less than 10)

If you have more engines / more api keys, you can override the config variables with following functions

$textResult = new LaravelSearchEngine(); // initialize

$textResult->setEngineId('someEngineId'); // sets the engine ID
$textResult->setApiKey('someApiId'); // sets the API key

$results =  $textResult->getResults('search text'); // get first 10 results for query 'search text'

If looking for only Search URl, Title & Description. By Default only 10 results are given

$textResult = new LaravelSearchEngine(); // initialize
$results =  $textResult->getResults('search text'); // get first 10 results for query 'search text'
$fewResults =  $textResult->getFewDetails(); // get first 10 results for query 'search text'

amark/laravelsearchengine 适用场景与选型建议

amark/laravelsearchengine 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 07 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 amark/laravelsearchengine 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 amark/laravelsearchengine 我们能提供哪些服务?
定制开发 / 二次开发

基于 amark/laravelsearchengine 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 9
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2022-07-08