PHPackages                             foysal50x/h3-php - 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. foysal50x/h3-php

ActiveLibrary

foysal50x/h3-php
================

PHP FFI bindings for Uber's H3 hexagonal hierarchical geospatial indexing system

v1.0.0(5mo ago)111.4k↓35.3%2MITPHPPHP &gt;=8.1CI passing

Since Nov 28Pushed 5mo agoCompare

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

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

 [![H3 PHP](cover.png)](cover.png) [![Build Status](https://github.com/Foysal50x/h3-php/actions/workflows/build-h3.yml/badge.svg)](https://github.com/Foysal50x/h3-php/actions/) [![Tests](https://github.com/Foysal50x/h3-php/actions/workflows/tests.yml/badge.svg)](https://github.com/Foysal50x/h3-php/actions/) [![Latest Stable Version](https://camo.githubusercontent.com/8f8e09de47e12a9998311e2278f50a8a145669ba19a85532ac12392df3e66feb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f666f7973616c3530782f68332d706870)](https://packagist.org/packages/foysal50x/h3-php)

H3 PHP FFI Bindings
===================

[](#h3-php-ffi-bindings)

PHP FFI bindings for [Uber's H3](https://h3geo.org/) hexagonal hierarchical geospatial indexing system.

Based on **H3 v4.4.1** - the latest version as of November 2025.

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- PHP FFI extension enabled (`ffi.enable=1` in php.ini)

Installation
------------

[](#installation)

### 1. Enable PHP FFI Extension

[](#1-enable-php-ffi-extension)

The FFI extension must be enabled in your `php.ini`:

```
; Enable the FFI extension
extension=ffi

; Enable FFI for all scripts (required for this library)
ffi.enable=true
```

**Note:** `ffi.enable` can be set to:

- `true` or `1` - Enable FFI for all scripts (recommended for development)
- `preload` - Enable FFI only in preloaded scripts (recommended for production)

To verify FFI is enabled:

```
php -m | grep FFI
php -i | grep ffi.enable
```

### 2. Install the PHP Package

[](#2-install-the-php-package)

```
composer require foysal50x/h3-php
```

This package includes **pre-built H3 libraries** for common platforms:

- macOS (Apple Silicon &amp; Intel)
- Linux (x64 &amp; ARM64)
- Windows (x64)

The library will automatically detect and use the appropriate bundled binary.

### 3. (Optional) System H3 Library

[](#3-optional-system-h3-library)

If the bundled library doesn't work for your platform, you can install the H3 C library system-wide:

**macOS (Homebrew):**

```
brew install h3
```

**Ubuntu/Debian:**

```
sudo apt install libh3-dev
```

**From source:**

```
git clone https://github.com/uber/h3.git
cd h3
cmake -B build
cmake --build build
sudo cmake --install build
```

Quick Start
-----------

[](#quick-start)

```
