PHPackages                             guanhui07/geohash - 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. guanhui07/geohash

ActiveLibrary

guanhui07/geohash
=================

geohash

v1.0.0(2y ago)18PHPPHP &gt;=7.4.0

Since Jul 19Pushed 1y ago1 watchersCompare

[ Source](https://github.com/guanhui07/geohash)[ Packagist](https://packagist.org/packages/guanhui07/geohash)[ RSS](/packages/guanhui07-geohash/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

安装
--

[](#安装)

`composer require guanhui07/geohash`

用法
--

[](#用法)

```
use Guanhui07/GeoHash;

$geohash = new Geohash();
//得到这点的hash值
$hash = $geohash->encode(39.98123848, 116.30683690);
//取前缀，前缀约长范围越小
$prefix = substr($hash, 0, 6);
//取出相邻八个区域
$neighbors = $geohash->neighbors($prefix);
array_push($neighbors, $prefix);

print_r($neighbors);
```

得到9个geohash值

```
Array
(
[top] => wx4eqx
[bottom] => wx4eqt
[right] => wx4eqy
[left] => wx4eqq
[topleft] => wx4eqr
[topright] => wx4eqz
[bottomright] => wx4eqv
[bottomleft] => wx4eqm
[0] => wx4eqw
)

```

```
CREATE TABLE `user_location` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '用户ID',
  `sex` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '0：未知，1：男，2：女',
  `last_login_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '最后活跃时间',
  `location` geometry NOT NULL  DEFAULT (point(0.0,0.0)) COMMENT '用户经纬度',
  `geohash3` varchar(20) GENERATED ALWAYS AS (st_geohash(`location`,3)) VIRTUAL,
  `geohash4` varchar(20) GENERATED ALWAYS AS (st_geohash(`location`,4)) VIRTUAL,
  `geohash5` varchar(20) GENERATED ALWAYS AS (st_geohash(`location`,5)) VIRTUAL,
  PRIMARY KEY (`id`),
  SPATIAL KEY `idx_location` (`location`),
  KEY `geohash3_login` (`sex`,`geohash3`,`last_login_time` DESC),
  KEY `geohash4_login` (`sex`,`geohash4`,`last_login_time` DESC),
  KEY `geohash5_login` (`sex`,`geohash5`,`last_login_time` DESC)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='用户附近搜索表';
```

其他资料：

扩展

geohash演示: wiki: 原理:

我的其他包：
------

[](#我的其他包)

 借鉴Laravel实现的 PHP Framework ，FPM模式、websocket使用的workerman、支持容器、PHP8特性attributes实现了路由注解、中间件注解、Laravel Orm等特性

 Swoole模式下 Redis连接池

 facade、门面 fpm模式下可使用

 基于swoole实现的crontab秒级定时任务

 基于 illuminate/database 做的连接池用于适配Swoole的协程环境

 高性能PHP Framework ，Cli模式，基于Swoole实现，常驻内存，协程框架，支持容器、切面、PHP8特性attributes实现了路由注解、中间件注解、支持Laravel Orm等特性

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance29

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

1025d ago

### Community

Maintainers

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

---

Top Contributors

[![guanhui07](https://avatars.githubusercontent.com/u/5820457?v=4)](https://github.com/guanhui07 "guanhui07 (6 commits)")

---

Tags

geohash

### Embed Badge

![Health badge](/badges/guanhui07-geohash/health.svg)

```
[![Health](https://phpackages.com/badges/guanhui07-geohash/health.svg)](https://phpackages.com/packages/guanhui07-geohash)
```

PHPackages © 2026

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