This project utilizes FFI to create a clean PHP wrapper around Uber's H3 C Library. The goal of this library is to minimize the complexity of creating a PHP extension and increase understanding of how this works to delegate to the C Library. This library requires PHP 7.4 since it uses FFI.
The test are a great place to look to see each of the supported methods in action. Currently, not all methods of the library are supported, but please feel free to PR any missing methods that you may need.
$h3 = new MichaelLindahl\H3\H3(H3::DYLIB);
$h3Index = $h3->geoToH3(40.689421843699, -74.044431399909, 10);
// $h3Index: '8a2a1072b59ffff'
This package is structed with H3.php
as the main entry point and shared location of the typedefs
used throughout the library. Each section of the API Reference is given it's own Trait
and Test
file to help maintain organization.
- This repository requires that the Uber H3 C Library be installed on your machine. The following are known installation methods for various platforms:
brew install h3
sudo apt install cmake --assume-yes
git clone https://github.com/uber/h3.git
cd h3
cmake -DBUILD_SHARED_LIBS=ON .
make -j4
sudo make install
sudo apt remove cmake --assume-yes
sudo cp /usr/local/lib/libh3.* /usr/lib/
sudo ldconfig
See my fork of laravel/vapor-php-build
here.
Contributions are welcomed. Please be kind, both in reviewing and contributing. Follow the project goals. And include tests.
Here are two articles that really helped my understanding of FFI and preloading: