Download the PHP package foysal50x/h3-php without Composer
On this page you can find all versions of the php package foysal50x/h3-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package h3-php
H3 PHP FFI Bindings
PHP FFI bindings for Uber's H3 hexagonal hierarchical geospatial indexing system.
Based on H3 v4.5.0 - the latest version as of May 2026.
Requirements
- PHP 8.1 or higher (tested up to PHP 8.5)
- PHP FFI extension enabled (
ffi.enable=1in php.ini)
Installation
1. Enable PHP FFI Extension
The FFI extension must be enabled in your php.ini:
Note: ffi.enable can be set to:
trueor1- Enable FFI for all scripts (recommended for development)preload- Enable FFI only in preloaded scripts (recommended for production)
To verify FFI is enabled:
2. Install the PHP Package
This package includes pre-built H3 libraries for common platforms:
- macOS (Apple Silicon & Intel)
- Linux (x64 & ARM64)
- Windows (x64)
The library will automatically detect and use the appropriate bundled binary.
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):
Ubuntu/Debian:
From source:
Quick Start
API Reference
Indexing Functions
Inspection Functions
Traversal Functions
Hierarchy Functions
Directed Edge Functions
Vertex Functions
Measurement Functions
Utility Functions
Local IJ Coordinates
Error Handling
All methods that can fail will throw an H3Exception:
Common Exceptions
The library will throw H3Exception in these cases:
-
FFI Extension Not Loaded
-
FFI Not Enabled
- H3 Library Not Found
Custom Library Path
If the H3 library is not in a standard location:
Singleton Pattern
For convenience, you can use the singleton pattern:
Note: If you try to get an instance with a different library path than the existing singleton, an exception will be thrown. Call resetInstance() first if you need to change the library path.
Security & Safety Features
This library includes several security and safety measures to prevent common FFI-related vulnerabilities:
Input Validation
All user inputs are validated before being passed to the C library:
Memory Safety
Grid operations have configurable limits to prevent memory exhaustion:
Descriptive Error Messages
Exceptions include detailed error information:
Resolution Guide
| Resolution | Avg Hex Area | Avg Edge Length |
|---|---|---|
| 0 | 4,357,449.416 km² | 1,281.256 km |
| 1 | 609,788.441 km² | 483.057 km |
| 2 | 86,801.780 km² | 182.512 km |
| 3 | 12,393.434 km² | 68.979 km |
| 4 | 1,770.347 km² | 26.071 km |
| 5 | 252.903 km² | 9.854 km |
| 6 | 36.129 km² | 3.724 km |
| 7 | 5.161 km² | 1.406 km |
| 8 | 0.737 km² | 531.414 m |
| 9 | 0.105 km² | 200.786 m |
| 10 | 0.015 km² | 75.863 m |
| 11 | 0.002 km² | 28.663 m |
| 12 | 307.092 m² | 10.830 m |
| 13 | 43.870 m² | 4.092 m |
| 14 | 6.267 m² | 1.546 m |
| 15 | 0.895 m² | 0.584 m |
Running Tests
License
MIT License - see LICENSE file.
Links
All versions of h3-php with dependencies
ext-ffi Version *