Skip to content

Commit 7e4cb24

Browse files
author
jayeshmepani
committed
docs: verify FFI claims and modernize dev stack
- Document complete FFI/CLI parity: 106 functions, constant parity, zero abstraction - Add Rector 2.x, enable strict types in Pint - Fix PHPStan issues, add Override attributes - Add automated VerificationTest against swetest CLI - Sync upstream to v2.10.3final + post-release fixes
1 parent 9fe955e commit 7e4cb24

11 files changed

Lines changed: 788 additions & 458 deletions

File tree

README.md

Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,37 @@
55
[![Latest Version on Packagist](https://img.shields.io/packagist/v/jayeshmepani/swiss-ephemeris-ffi.svg?style=flat-square)](https://packagist.org/packages/jayeshmepani/swiss-ephemeris-ffi)
66
[![Total Downloads](https://img.shields.io/packagist/dt/jayeshmepani/swiss-ephemeris-ffi.svg?style=flat-square)](https://packagist.org/packages/jayeshmepani/swiss-ephemeris-ffi)
77

8+
PHP 8.3+ FFI wrapper for the Swiss Ephemeris C library.
89

9-
100% precise 1:1 FFI mapping of the Swiss Ephemeris C library for PHP 8.3+. Complete wrapper for all 106 functions.
10+
This package is designed to expose the Swiss Ephemeris C API to PHP through FFI, without shelling out to the `swetest` command-line tool.
11+
12+
**Zero abstraction. Native-level FFI. Verified output parity with Swiss Ephemeris C engine.**
13+
14+
> 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.
15+
>
16+
> The wrapper performs no additional calculations, transformations, or rounding, ensuring direct memory-level interaction with the C engine.
17+
>
18+
> 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.
19+
20+
## Latest Upstream Status
21+
22+
Checked against upstream on **April 25, 2026**.
23+
24+
- **Latest upstream release tag**: `v2.10.3final` released on **April 14, 2026**.
25+
- **Current upstream `master` checked**: commit `2f18c14` from **April 18, 2026** (`fixed bug in semo4200.se1`).
26+
- **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.
27+
- **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.
28+
- **Compatibility note**: upstream states that the rebuilt `.se1` files remain compatible with older Swiss Ephemeris versions at least back to release 1.67.
29+
- **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`.
30+
- **Internal Swiss Ephemeris version string**: the upstream C header still defines `SE_VERSION` as `2.10.03`.
31+
32+
See [`VERSION.md`](VERSION.md) and [`UPSTREAM_SYNC.md`](UPSTREAM_SYNC.md) for detailed version tracking.
1033

1134
## Requirements
1235

13-
- PHP 8.3+ with FFI extension
14-
- `ffi.enable=1` in php.ini
36+
- PHP `^8.3`
37+
- PHP FFI extension (`ext-ffi`)
38+
- FFI enabled in PHP configuration. Depending on your environment, this usually means setting `ffi.enable=true`, or configuring FFI preload mode correctly.
1539

1640
## Installation
1741

@@ -25,15 +49,24 @@ composer require jayeshmepani/swiss-ephemeris-ffi
2549
use SwissEph\FFI\SwissEphFFI;
2650

2751
$sweph = new SwissEphFFI();
52+
2853
$jd = $sweph->swe_julday(2000, 1, 1, 12.0, SwissEphFFI::SE_GREG_CAL);
2954

3055
$xx = $sweph->getFFI()->new("double[6]");
3156
$serr = $sweph->getFFI()->new("char[256]");
3257

33-
$result = $sweph->swe_calc_ut($jd, SwissEphFFI::SE_SUN, SwissEphFFI::SEFLG_SPEED, $xx, $serr);
58+
$result = $sweph->swe_calc_ut(
59+
$jd,
60+
SwissEphFFI::SE_SUN,
61+
SwissEphFFI::SEFLG_SPEED,
62+
$xx,
63+
$serr
64+
);
3465

3566
if ($result >= 0) {
3667
echo "Sun Longitude: " . $xx[0] . "°\n";
68+
} else {
69+
echo "Swiss Ephemeris error: " . $sweph->getFFI()->string($serr) . "\n";
3770
}
3871
```
3972

@@ -42,14 +75,26 @@ if ($result >= 0) {
4275
**[Read the full documentation →](https://jayeshmepani.github.io/Swiss-Ephemeris-PHP/)**
4376

4477
The documentation covers:
45-
- Installation (Linux, macOS, Windows)
78+
79+
- Installation on Linux, macOS, and Windows
4680
- FFI configuration
47-
- Ephemeris files setup
48-
- All 106 API functions
49-
- Examples (tropical, sidereal, houses)
81+
- Ephemeris file setup
82+
- Swiss Ephemeris API usage
83+
- Examples for tropical, sidereal, and house calculations
5084
- Laravel integration
5185
- Troubleshooting
5286

87+
## Verification Sources
88+
89+
- Upstream repository: <https://github.com/aloistr/swisseph>
90+
- Upstream releases: <https://github.com/aloistr/swisseph/releases>
91+
- Upstream compare: <https://github.com/aloistr/swisseph/compare/v2.10.3final...master>
92+
- Packagist package: <https://packagist.org/packages/jayeshmepani/swiss-ephemeris-ffi>
93+
- PHP FFI configuration: <https://www.php.net/manual/en/ffi.configuration.php>
94+
- Swiss Ephemeris official information: <https://www.astro.com/swisseph/swephinfo_e.htm>
95+
5396
## License
5497

55-
AGPL-3.0. See [LICENSE](LICENSE) for details.
98+
This package metadata declares **AGPL-3.0-or-later**.
99+
100+
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.

0 commit comments

Comments
 (0)