jayeshmepani/swiss-ephemeris-ffi
PHP 8.3+ FFI wrapper exposing all 106 Swiss Ephemeris C API functions with full constant and signature parity. Zero abstraction or extra math, verified bit-level output parity against the official swetest CLI for planets, houses, eclipses, and edge dates.
swetest CLI. That means a PM can scope natal charts, transits and progressions, house systems, eclipse and retrograde flags, rise/set and meridian transits, sidereal/Vedic ayanamsa modes, and fixed-star work knowing the astronomy is not the delivery risk. The uncertainty moves to product surface — rendering, UX, pricing — where it belongs.php-sweph — carries the same upstream-tracking burden plus rebuild-on-PHP-upgrade costs and materially harder distribution across platforms. Recommendation: take the Composer dependency and spend the engineering budget on the typed domain layer, chart rendering, onboarding, and API design.EphemerisService / AstrologyCalculator interface so future roadmap items — solar returns, synastry, progressions, asteroid support (upstream documents 760k+ numbered asteroids), additional house systems, sidereal modes — are additive rather than a re-architecture. The FFI layer must not leak into controllers, queued jobs, or Blade templates; "zero abstraction" is a property of the wrapper, not an invitation for the app to handle raw FFI\CData.storage/app/swisseph/ publish target (moved out of public/ in v1.1.1) is a deployment decision with real consequences: native libraries and ephemeris data live outside the web root, there is no swetest shell-out to sandbox, and no external CLI dependency baked into the container image. Standardize on that layout and document it as the supported deployment shape before the first production release.php-sweph C extension showing bit-perfect output and competitive performance, plus explicit upstream version tracking (v2.10.3final, DE441-rebuilt .se1 files, VERSION.md, UPSTREAM_SYNC.md). For a package this small, that is unusually strong evidence, and it lets a PM answer "why not just call a third-party API?" with data rather than opinion.Adopt when:
ext-ffi with ffi.enable=true (or correct preload configuration) in every environment: local, CI, staging, production. Validate this against your actual host before committing the roadmap — shared hosting, some managed PHP platforms, and hardened container policies disallow FFI outright.storage/app/swisseph/ matches how you already deploy.swetest, and a documented performance audit against the C extension.Look elsewhere or defer when:
For executives — one paragraph: "We can ship professional-grade astronomical accuracy without building or maintaining a C bridge ourselves. This package gives our Laravel application direct, unmodified access to the Swiss Ephemeris engine — the C library the astrology and astronomy industries treat as the reference implementation — with all 106 functions exposed and outputs verified bit-for-bit against the official reference CLI. The engineering cost drops from months of specialist native-code work to a Composer dependency, which frees the team to build the differentiated product: charts, UX, and commercial features. Two caveats deserve a decision now rather than later: it requires the PHP FFI extension on every host, and the upstream ephemeris data is AGPL-licensed with a paid commercial license option, so we should settle the licensing posture before we price the feature."
For engineering — the short version:
It is a thin, honest wrapper: 1:1 signature and constant parity with swe_*, no reshaping of return values, no hidden buffers, and no shell-out to swetest. It ships a Laravel facade and publishes bundled multi-platform native libraries to storage/app/swisseph/ — outside the web root. Requirements are PHP 8.3+ and ext-ffi enabled, with preload configured correctly. The integration rule is non-negotiable: wrap it in an internal service and expose typed DTOs, because the raw API hands you double[6] arrays and char[256] error buffers, and the FFI layer is not thread-safe. Keep the adapter thin — the wrapper is a single-maintainer project, so assume you may fork it and price that in at roughly a day, not a quarter. The published benchmark vs. php-sweph shows bit-perfect parity and competitive throughput, so the "just use the C extension" objection is already answered with evidence.
How can I help you explore Laravel packages today?