Go-powered high-performance tools for Laravel. Offloads CPU-intensive operations to compiled Go binaries for significant speed improvements over pure PHP.
- H3 — Uber's H3 geospatial indexing (lat/lng to cell, k-ring, distance, polyfill)
- Sets — Fast set operations on large collections (intersect, union, diff)
- DbCompare — Cross-database table comparison (MySQL & PostgreSQL)
- PHP 8.2+
- Laravel 11.x or 12.x
composer require melkmeshi/laravel-go-toolsDownload the Go binary for your platform:
php artisan go-tools:installOptionally publish the config:
php artisan vendor:publish --tag=go-tools-configCheck installation status:
php artisan go-tools:statususe Melkmeshi\GoTools\Facades\H3;
// Convert coordinates to H3 cell
$cell = H3::latLngToCell(37.7749, -122.4194, 10);
echo $cell->index; // e.g. "8a283082800ffff"
// Get neighboring cells within k steps
$neighbors = H3::kRing($cell->index, 1);
// Grid distance between two cells
$cellB = H3::latLngToCell(37.7750, -122.4180, 10);
$distance = H3::gridDistance($cell->index, $cellB->index);
// Fill a polygon with H3 cells
$cells = H3::polygonToCells([
[37.7749, -122.4194],
[37.3382, -121.8863],
[37.9, -122.5],
], 8);use Melkmeshi\GoTools\Facades\Sets;
Sets::intersect([1, 2, 3, 4], [3, 4, 5, 6]); // [3, 4]
Sets::union([1, 2, 3], [3, 4, 5]); // [1, 2, 3, 4, 5]
Sets::diff([1, 2, 3, 4], [3, 4, 5, 6]); // [1, 2]Compare ID sets across two database connections:
use Melkmeshi\GoTools\Facades\DbCompare;
// Using Laravel connection names
$result = DbCompare::compareConnections(
'mysql',
'SELECT id FROM orders',
'pgsql',
'SELECT id FROM sale_order',
storage_path('app/compare-results'),
);
echo $result->countA; // total IDs in source A
echo $result->countB; // total IDs in source B
echo $result->onlyACount; // IDs only in A
echo $result->onlyBCount; // IDs only in B
echo $result->bothCount; // IDs in both
echo $result->onlyAFile; // CSV file path
echo $result->onlyBFile; // CSV file path
// Or using raw database config arrays
$result = DbCompare::compare(
config('database.connections.mysql'),
'SELECT id FROM orders',
config('database.connections.pgsql'),
'SELECT id FROM sale_order',
);Environment variables:
| Variable | Default | Description |
|---|---|---|
GO_TOOLS_BINARY_PATH |
auto-detected | Custom path to the Go binary |
GO_TOOLS_TIMEOUT |
30 |
Default command timeout (seconds) |
GO_TOOLS_DB_COMPARE_TIMEOUT |
300 |
DB compare timeout (seconds) |
| Platform | Architecture |
|---|---|
| macOS | Apple Silicon (arm64) |
| Linux | x86_64 (amd64) |
./scripts/build.shBuilds Go binaries for all supported platforms into dist/. Requires zig for cross-compilation.
./scripts/release.sh v0.2.0Builds all binaries and creates a GitHub release with the assets attached.
MIT