PHPackages                             jayeshmepani/swiss-ephemeris-ffi - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. jayeshmepani/swiss-ephemeris-ffi

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jayeshmepani/swiss-ephemeris-ffi
================================

Complete 100% 1:1 PHP FFI Wrapper for the Swiss Ephemeris C Library - Direct C function calls with zero abstraction for maximum astronomical precision

v1.1.1(1mo ago)3365↑175.8%2AGPL-3.0-or-laterPHPPHP ^8.3CI passing

Since Mar 24Pushed 1mo agoCompare

[ Source](https://github.com/jayeshmepani/Swiss-Ephemeris-PHP)[ Packagist](https://packagist.org/packages/jayeshmepani/swiss-ephemeris-ffi)[ Docs](https://github.com/jayeshmepani/Swiss-Ephemeris-PHP)[ GitHub Sponsors](https://github.com/sponsors/jayeshmepani)[ RSS](/packages/jayeshmepani-swiss-ephemeris-ffi/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (4)Dependencies (14)Versions (4)Used By (2)

Swiss Ephemeris PHP FFI
=======================

[](#swiss-ephemeris-php-ffi)

[![PHP Version](https://camo.githubusercontent.com/5db4c076eff39ebe4683c5e75fe00adef8f907d7313e4ee39f395725a4777c8b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6a61796573686d6570616e692f73776973732d657068656d657269732d666669)](https://packagist.org/packages/jayeshmepani/swiss-ephemeris-ffi)[![License](https://camo.githubusercontent.com/df7a3e612c98bca541e286e40aaa1bfbac3211d25e32181fd997e7473e26a90a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6a61796573686d6570616e692f53776973732d457068656d657269732d504850)](LICENSE)[![Latest Version on Packagist](https://camo.githubusercontent.com/9a008d5210beed330dc6be46ba671a2aae632521fc5194057e0613d7e45631e2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a61796573686d6570616e692f73776973732d657068656d657269732d6666692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jayeshmepani/swiss-ephemeris-ffi)[![Total Downloads](https://camo.githubusercontent.com/3afe2de393cb06d3314717176ced3c7e705a8a94d052fea55c86d4b4615c35ba/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a61796573686d6570616e692f73776973732d657068656d657269732d6666692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jayeshmepani/swiss-ephemeris-ffi)

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 `swetest` CLI using automated PHPUnit tests, demonstrating bit-level parity in verified test scenarios for planetary positions, house systems, eclipses, and edge-date calculations.

Latest Upstream Status
----------------------

[](#latest-upstream-status)

Checked against upstream on **April 25, 2026**.

- **Latest upstream release tag**: `v2.10.3final` released on **April 14, 2026**.
- **Current upstream `master` checked**: commit `2f18c14` from **April 18, 2026** (`fixed bug in semo4200.se1`).
- **Swiss Ephemeris 3.0**: announced by upstream as the next major source-code release, but no public `v3.0` tag was available at the time of this check.
- **DE441 data update**: upstream states that, as of **April 14, 2026**, all `.se1` data files for planets and asteroids were rebuilt with JPL Ephemeris DE441.
- **Compatibility note**: upstream states that the rebuilt `.se1` files remain compatible with older Swiss Ephemeris versions at least back to release 1.67.
- **Asteroid data**: upstream documents more than **760,000 numbered asteroids** and more than **25,000 named asteroids**. Commit history also records asteroid list updates through numbered asteroid `793066`.
- **Internal Swiss Ephemeris version string**: the upstream C header still defines `SE_VERSION` as `2.10.03`.

See [`VERSION.md`](VERSION.md) and [`UPSTREAM_SYNC.md`](UPSTREAM_SYNC.md) for detailed version tracking.

Requirements
------------

[](#requirements)

- PHP `^8.3`
- PHP FFI extension (`ext-ffi`)
- FFI enabled in PHP configuration. Depending on your environment, this usually means setting `ffi.enable=true`, or configuring FFI preload mode correctly.

Installation
------------

[](#installation)

```
composer require jayeshmepani/swiss-ephemeris-ffi
```

Quick Start
-----------

[](#quick-start)

```
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";
}
```

Performance Audit
-----------------

[](#performance-audit)

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 →](https://jayeshmepani.github.io/Swiss-Ephemeris-PHP/benchmark/benchmark.html)**

The audit demonstrates **bit-perfect accuracy** and highly competitive performance across all 106 Swiss Ephemeris functions.

Documentation
-------------

[](#documentation)

**[Read the full documentation →](https://jayeshmepani.github.io/Swiss-Ephemeris-PHP/)**

The documentation covers:

- Installation on Linux, macOS, and Windows
- FFI configuration
- Ephemeris file setup
- Swiss Ephemeris API usage
- Examples for tropical, sidereal, and house calculations
- Laravel integration
- Troubleshooting

Verification Sources
--------------------

[](#verification-sources)

- Upstream repository:
- Upstream releases:
- Upstream compare:
- Packagist package:
- PHP FFI configuration:
- Swiss Ephemeris official information: [https://www.astro.com/swisseph/swephinfo\_e.htm](https://www.astro.com/swisseph/swephinfo_e.htm)

License
-------

[](#license)

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.

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance89

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 72.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~19 days

Total

3

Last Release

56d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/32cb5a476cac8bc43ffdf0769601a7425bc7ada6ec2291ee47c87441469035f0?d=identicon)[jayeshmepani](/maintainers/jayeshmepani)

---

Top Contributors

[![jayeshmepani](https://avatars.githubusercontent.com/u/112438589?v=4)](https://github.com/jayeshmepani "jayeshmepani (24 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (9 commits)")

---

Tags

astrologyastronomical-calculationsastronomyayanamsacomposereclipseephemerisffihoroscopehousesjyotishkundlilaravelphpphp-libraryplanetary-positionssiderealswiss-ephemerisvedic-astrologyzodiaclaravel-packagePHP LibraryEclipseffihoroscopeastrologyastronomyephemerisjyotishvedic astrologyphp-ffihouseskundliswiss-ephemerisastrology-apibirth-chartplanetary-positionsayanamsasiderealtropical

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/jayeshmepani-swiss-ephemeris-ffi/health.svg)

```
[![Health](https://phpackages.com/badges/jayeshmepani-swiss-ephemeris-ffi/health.svg)](https://phpackages.com/packages/jayeshmepani-swiss-ephemeris-ffi)
```

###  Alternatives

[realrashid/sweet-alert

Laravel Sweet Alert Is A Package For Laravel Provides An Easy Way To Display Alert Messages Using The SweetAlert2 Library.

1.2k3.1M22](/packages/realrashid-sweet-alert)[ashallendesign/short-url

A Laravel package for creating shortened URLs for your web apps.

1.4k2.2M5](/packages/ashallendesign-short-url)[lodash-php/lodash-php

A port of Lodash to PHP

524741.7k5](/packages/lodash-php-lodash-php)[phalcon/ide-stubs

The most complete Phalcon Framework IDE stubs library which enables autocompletion in modern IDEs.

1643.2M128](/packages/phalcon-ide-stubs)[intervention/zodiac

Zodiac Sign Calculator

57198.1k](/packages/intervention-zodiac)[imanghafoori/laravel-nullable

A package to help you write expressive defensive code in a functional manner

151461.3k6](/packages/imanghafoori-laravel-nullable)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
