jayeshmepani/swiss-ephemeris-ffi
PHP 8.3+ FFI wrapper for the Swiss Ephemeris C library. Exposes all 106 public API functions with 1:1 constant/signature parity and zero abstraction. No swetest shelling; outputs verified for parity via PHPUnit against swetest.
PHP 8.3+ FFI wrapper for the Swiss Ephemeris C library.
This package is designed to expose the Swiss Ephemeris C API to PHP through FFI, without shelling out to the swetest command-line tool.
Zero abstraction. Native-level FFI. Verified output parity with Swiss Ephemeris C engine.
Swiss Ephemeris PHP FFI provides a zero-abstraction, 1:1 mapping of the native Swiss Ephemeris C library. All 106 public API functions are exposed with complete constant and signature parity.
The wrapper performs no additional calculations, transformations, or rounding, ensuring direct memory-level interaction with the C engine.
Outputs are verified against the official
swetestCLI using automated PHPUnit tests, demonstrating bit-level parity in verified test scenarios for planetary positions, house systems, eclipses, and edge-date calculations.
Checked against upstream on April 25, 2026.
v2.10.3final released on April 14, 2026.master checked: commit 2f18c14 from April 18, 2026 (fixed bug in semo4200.se1).v3.0 tag was available at the time of this check..se1 data files for planets and asteroids were rebuilt with JPL Ephemeris DE441..se1 files remain compatible with older Swiss Ephemeris versions at least back to release 1.67.793066.SE_VERSION as 2.10.03.See VERSION.md and UPSTREAM_SYNC.md for detailed version tracking.
^8.3ext-ffi)ffi.enable=true, or configuring FFI preload mode correctly.composer require jayeshmepani/swiss-ephemeris-ffi
use SwissEph\FFI\SwissEphFFI;
$sweph = new SwissEphFFI();
$jd = $sweph->swe_julday(2000, 1, 1, 12.0, SwissEphFFI::SE_GREG_CAL);
$xx = $sweph->getFFI()->new("double[6]");
$serr = $sweph->getFFI()->new("char[256]");
$result = $sweph->swe_calc_ut(
$jd,
SwissEphFFI::SE_SUN,
SwissEphFFI::SEFLG_SPEED,
$xx,
$serr
);
if ($result >= 0) {
echo "Sun Longitude: " . $xx[0] . "°\n";
} else {
echo "Swiss Ephemeris error: " . $sweph->getFFI()->string($serr) . "\n";
}
We have conducted a rigorous side-by-side benchmark comparing this FFI implementation against the native php-sweph C-extension.
View the Interactive Performance Audit →
The audit demonstrates bit-perfect accuracy and highly competitive performance across all 106 Swiss Ephemeris functions.
The documentation covers:
This package metadata declares AGPL-3.0-or-later.
The upstream Swiss Ephemeris C library and ephemeris data are distributed under Astrodienst's dual licensing model: AGPL or Swiss Ephemeris Professional License. If you use Swiss Ephemeris in commercial or closed-source software, or in a public SaaS/web service, review Astrodienst's license terms before use.
How can I help you explore Laravel packages today?