PHPackages                             linshunwei/laravel\_redis\_lbs - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. linshunwei/laravel\_redis\_lbs

ActiveLibrary[Caching](/categories/caching)

linshunwei/laravel\_redis\_lbs
==============================

v1.2.0(6y ago)0183MITPHPPHP &gt;=5.4.0

Since Mar 13Pushed 6y agoCompare

[ Source](https://github.com/linshunwei/laravel_redis_lbs)[ Packagist](https://packagist.org/packages/linshunwei/laravel_redis_lbs)[ RSS](/packages/linshunwei-laravel-redis-lbs/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (1)Versions (7)Used By (0)

安装
==

[](#安装)

使用 composer

```
composer require linshunwei/laravel_redis_lbs
```

在配置文件中添加服务提供者（Laravel5.5 有自动添加）

```
'providers' => [
    //...
    Linshunwei\LaravelRedisLbs\RedisLbsProvider::class,
    //...
],
```

然后执行

```
php artisan vendor:publish --provider="Linshunwei\LaravelRedisLbs\RedisLbsProvider"

```

将生成 `config/redis_lbs.php` 配置文件，配置文件中的

```
//是否应用在laravel当中
'is_laravel' => false,
//使用laravel的redis版本
'laravel_redis' => 'default',

```

当 `is_laravel => true` 的时候， `laravel_redis => 'default'` 将调用 `config/database.php`下的redis相应的配置

使用方式

```
use Linshunwei\LaravelRedisLbs\RedisLbs;

 $lbs = new RedisLbs();
 $lbs->del('gao1');

```

\#基本操作

添加
--

[](#添加)

```
$add_params = [
    [
        'name' => 'yabao_road',
        'long' => '116.43620200729366',
        'lat' => '39.916880160714435'
    ],
    [
        'name' => 'jianguomen',
        'long' => '116.4356870231628',
        'lat' => '39.908560377800676'
    ],
    [
        'name' => 'chaoyangmen',
        'long' => '116.4345336732864',
        'lat' => '39.924466658329585'
    ],
    [
        'name' => 'galaxy_soho',
        'long' => '116.4335788068771',
        'lat' => '39.921372916981106'
    ],
    [
        'name' => 'cofco',
        'long' => '116.43564410781856',
        'lat' => '39.92024564137184'
    ],
    [
        'name' => 'fesco',
        'long' => '116.435182767868',
        'lat' => '39.91811857809279'
    ],

];
/**
 * 在集合中新加一个坐标
 * @param array $params
 *  结构是 ['name'=>'xxx','long'=>'1.2321','lat'=>'1.3112']或者[['name'=>'xxx','long'=>'1.2321','lat'=>'1.3112']]
 * @param null $key
 * @return int
 */
$res = $lbs->add($add_params);

返回
int 6

```

删除
--

[](#删除)

```
/**
 * 删除集合中指定元素
 * @param $name
 * @param null $key  默认存在集合，可以指定
 * @return int
 */
$res = $lbs->del('gao1');

返回
int 0 或 1

如果是指定的集合名就
$res = $lbs->del('gao1','set-name');

```

用坐标查询附近的单位
----------

[](#用坐标查询附近的单位)

```
/**
 * 查询范围内元素，如果不转 key就用默认的
 * @param $long     经度
 * @param $lat      纬度
 * @param $radius   范围
 * @param $unit     单位  (仅支持 m,km,ft,mi)
 * @param null $key 集合名
 * @return mixed
 */
$search = $lbs->search('116.435182767868','39.91811857809279',500,'m');

返回数组
array:4 [▼
  0 => array:2 [
    "name" => "fesco"
    "dist" => "0.1250"
  ]
  1 => array:2 [
    "name" => "yabao_road"
    "dist" => "162.8454"
  ]
  2 => array:2 [
    "name" => "cofco"
    "dist" => "239.7758"
  ]
  3 => array:2 [
    "name" => "galaxy_soho"
    "dist" => "386.9165"
  ]
]

```

根据已有的位置查询
---------

[](#根据已有的位置查询)

```
/**
 * 根据集合中的元素查询范围内元素，如果不转 key就用默认的
 * @param $name         集合中的元素名
 * @param $radius       范围
 * @param $unit         单位
 * @param null $key     集合名
 * @return mixed
 */
$search = $lbs->searchByMembers('fesco',500,'m');

返回数组
array:4 [▼
  0 => array:2 [▼
    "name" => "fesco"
    "dist" => "0.1250"
  ]
  1 => array:2 [▼
    "name" => "yabao_road"
    "dist" => "162.8454"
  ]
  2 => array:2 [▼
    "name" => "cofco"
    "dist" => "239.7758"
  ]
  3 => array:2 [▼
    "name" => "galaxy_soho"
    "dist" => "386.9165"
  ]
]

```

列出集合的所有值（其实就是 zrange)
---------------------

[](#列出集合的所有值其实就是-zrange)

```
/**
 * 列出集合中的内容
 * @param $key          集合的key
 * @param int $start    起始位置
 * @param int $end      结束位置 -1 为直到末尾
 * @return array
 */
$list = $lbs->list($test->geoset_name,2,-1);

返回数组
array:6 [▼
  0 => "jianguomen"
  1 => "yabao_road"
  2 => "fesco"
  3 => "cofco"
  4 => "galaxy_soho"
  5 => "chaoyangmen"
]

```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~162 days

Recently: every ~1 days

Total

6

Last Release

2535d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3fe2545ef1e7a6237d40d28020530c2f32f22a7f35993bc55e2a1baa2ab983ae?d=identicon)[linshunwei](/maintainers/linshunwei)

---

Top Contributors

[![gaopengfei123123](https://avatars.githubusercontent.com/u/20946369?v=4)](https://github.com/gaopengfei123123 "gaopengfei123123 (16 commits)")

### Embed Badge

![Health badge](/badges/linshunwei-laravel-redis-lbs/health.svg)

```
[![Health](https://phpackages.com/badges/linshunwei-laravel-redis-lbs/health.svg)](https://phpackages.com/packages/linshunwei-laravel-redis-lbs)
```

###  Alternatives

[rhubarbgroup/redis-cache

A persistent object cache backend for WordPress powered by Redis. Supports Predis, PhpRedis, Relay, replication, sentinels, clustering and WP-CLI.

51795.3k1](/packages/rhubarbgroup-redis-cache)[monospice/laravel-redis-sentinel-drivers

Redis Sentinel integration for Laravel and Lumen.

103830.5k](/packages/monospice-laravel-redis-sentinel-drivers)[jamescauwelier/psredis

Sentinel client for the popular php redis client

77392.9k5](/packages/jamescauwelier-psredis)[cache/predis-adapter

A PSR-6 cache implementation using Redis (Predis). This implementation supports tags

272.6M13](/packages/cache-predis-adapter)[symfony-bundles/redis-bundle

Symfony Redis Bundle

271.1M5](/packages/symfony-bundles-redis-bundle)[pdffiller/qless-php

PHP Bindings for qless

29113.2k1](/packages/pdffiller-qless-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
