jayeshmepani/jpl-moshier-ephemeris-php
PHP 8.3+ FFI wrapper for the JPL Moshier Ephemeris C library. Exposes all public jme_* functions and JME_* constants with no output reshaping. Supports AUTO/JPL/MOSHIER/VSOP engines and direct JPL/CALCEPH kernel access via shared libs.
libs/ubuntu22/, libs/ubuntu24/, macOS arm64, Windows MSVC 2022) reduces deployment friction by automating OS/glibc/Darwin kernel detection. This aligns better with multi-platform Laravel deployments (e.g., AWS EC2, macOS CI, Windows containers).LD_LIBRARY_PATH/DYLD_LIBRARY_PATH configuration in most cases. However, custom paths (e.g., /opt/jme/libs/) may still require explicit setup.libs/ directory structure is additive, not breaking. Existing deployments with static binaries in vendor/bin/ remain functional.CelestialEphemerisService) require no updates.RuntimeException if the OS isn’t recognized, improving debuggability.libs/ isn’t in the expected location, FFI initialization fails silently until runtime. Validate paths early in Laravel’s bootstrap (e.g., bootstrap/app.php).jme_* function signatures (e.g., variadic args) might still have untested edge cases.libs/ is mounted correctly.)libs/ directory existence at bootstrap (e.g., EphemerisService::ensureNativeLibs()).use JplMoshier\Ephemeris;
class EphemerisService extends ServiceProvider {
public function boot() {
if (!Ephemeris::isLibraryLoaded()) {
throw new RuntimeException("Native ephemeris libraries not found. Check libs/ directory.");
}
}
}
DECIMAL(38,20)) for ephemeris data.libjme deployment (static vs. dynamic paths).composer.json to include the new libs/ structure:
"extra": {
"native-libs": ["libs/ubuntu22/libjme.so", "libs/macos-arm64/libjme.dylib"]
}
Dockerfile to copy libs/ into the container:
COPY libs/ /usr/local/share/jme/libs/
try {
$position = Ephemeris::jme_conj(...);
} catch (RuntimeException $e) {
if (str_contains($e->getMessage(), 'unsupported')) {
return response()->view('errors.unsupported_os');
}
throw $e;
}
libs/ path handling.libs/ directory (from the package’s vendor/)./libs
/ubuntu22
libjme.so
/macos-arm64
libjme.dylib
/windows
jme.dll
libs/ at startup:
public function register() {
if (!file_exists(__DIR__.'/../../libs')) {
throw new RuntimeException("Ephemeris libraries directory missing.");
}
}
php artisan tinker
>>> \JplMoshier\Ephemeris::getLibraryVersion();
libs/ in Docker builds:
- run: cp -r vendor/jpl-moshier/ephemeris/libs /usr/local/share/
libjme for ABI changes that break dynamic loading (e.g., new glibc symbols).composer.json to avoid runtime incompatibilities.libs/ updates via composer post-install script:
[ -d "libs" ] || mkdir libs && cp -r vendor/jpl-moshier/ephemeris/libs/* libs/
README.md (e.g., "Tested on Ubuntu 22.0How can I help you explore Laravel packages today?