Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Swiss Ephemeris Ffi Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Feature viability in precision-critical domains. Every one of the 106 public Swiss Ephemeris C functions is exposed 1:1, with no rounding, transformation, or interpolation layer, and the outputs are pinned by PHPUnit parity tests against the official 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.
  • Build vs. buy: buy the bridge, own the product layer. Hand-rolling a C-to-PHP FFI bridge, mapping constants and signatures, and maintaining a regression suite against upstream is months of specialist work that produces zero differentiation. The realistic alternative — a compiled C extension such as 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.
  • Roadmap sequencing through an architectural seam. Treat this as infrastructure, never as feature code. Put it behind an internal 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.
  • Laravel delivery and security posture. The facade plus the 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.
  • Segment fit and where the value actually accrues. Consumer astrology SaaS (horoscopes, compatibility, daily transits), sidereal/Vedic products where ayanamsa accuracy is the value proposition, academic and research reproducibility, and simulation/gaming celestial mechanics. Nuance worth raising early: high-volume consumer endpoints are usually better served by precomputed tables for the handful of popular bodies and dates. The FFI path earns its cost on on-demand, arbitrary-date, arbitrary-body queries — the long tail of the product, not the homepage.
  • Licensing and data provenance as product constraints, not cleanup tasks. Ephemeris data and the upstream C library are AGPL-3.0 from Astrodienst, with a paid Swiss Ephemeris Professional License offered for closed-source or commercial SaaS use. This is a pricing and legal decision that belongs on the roadmap before a feature is scoped, because it can move unit economics or force an open-source release of the service layer. Budget for the license the same way infrastructure is budgeted, and decide the open/closed posture of the surrounding service deliberately.
  • Claims you can defend in a review. There is a published side-by-side benchmark against the 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.

When to Consider This Package

Adopt when:

  • You need Swiss Ephemeris-grade accuracy and the complete API surface — houses, eclipses, heliacal events, sidereal modes, fixed stars — from PHP, without shelling out to a CLI and without reimplementing the math.
  • You are on PHP 8.3+ and can guarantee 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.
  • Your stack is Laravel and a facade plus conventional publishing of bundled multi-platform native libraries to storage/app/swisseph/ matches how you already deploy.
  • You value provenance and verifiability: pinned upstream tracking, automated parity tests against swetest, and a documented performance audit against the C extension.
  • You accept the operational shape: singleton in a long-lived process, bundled binaries for common platforms, and custom library path support for teams with their own builds.
  • You are committed to wrapping it. Plan typed result objects and an adapter on day one, and staff for a PHP engineer comfortable with FFI semantics — pointer lifetimes, fixed-size buffers, and error-string handling are not skills you can assume.

Look elsewhere or defer when:

  • Licensing is unresolved. AGPL-3.0 plus Astrodienst's dual-license model is a hard blocker for closed-source commercial products and public SaaS absent the Professional License. This alone disqualifies the package for many organizations until legal signs off.
  • You cannot run FFI — PHP below 8.3, restricted hosting, hardened containers, or an organizational policy against native extensions and FFI. Evaluate a hosted ephemeris API or precomputed tables instead.
  • Precision is not the differentiator. If the product needs sun-sign content, moon phases, and approximate positions, a pure-PHP library is cheaper, safer, and easier to operate. Precision you cannot monetize is just operational risk.
  • You need in-process concurrency and fan-out. The FFI layer is not thread-safe; correctness depends on synchronous, isolated execution. Plan queue workers, process isolation, or a dedicated ephemeris microservice rather than parallel calls inside one request.
  • You require vendor stability signals. Six stars, zero dependents, and a single maintainer describe a niche single-person project. The underlying C library is industrially trusted; the PHP wrapper's longevity is not guaranteed. Pin a version indefinitely or plan to fork — and keep your own wrapper thin enough that a fork is a weekend, not a quarter.
  • You need managed support, SLAs, or a compliance paper trail that an internal team cannot supply.

How to Pitch It (Stakeholders)

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.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core