jayeshmepani/swiss-ephemeris-ffi
Composer 安装命令:
composer require 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
关键字:
README 文档
README
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.
Latest Upstream Status
Checked against upstream on April 25, 2026.
- Latest upstream release tag:
v2.10.3finalreleased on April 14, 2026. - Current upstream
masterchecked: commit2f18c14from 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.0tag was available at the time of this check. - DE441 data update: upstream states that, as of April 14, 2026, all
.se1data files for planets and asteroids were rebuilt with JPL Ephemeris DE441. - Compatibility note: upstream states that the rebuilt
.se1files 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_VERSIONas2.10.03.
See VERSION.md and UPSTREAM_SYNC.md for detailed version tracking.
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
composer require jayeshmepani/swiss-ephemeris-ffi
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
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.
Documentation
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
- Upstream repository: https://github.com/aloistr/swisseph
- Upstream releases: https://github.com/aloistr/swisseph/releases
- Upstream compare: https://github.com/aloistr/swisseph/compare/v2.10.3final...master
- Packagist package: https://packagist.org/packages/jayeshmepani/swiss-ephemeris-ffi
- PHP FFI configuration: https://www.php.net/manual/en/ffi.configuration.php
- Swiss Ephemeris official information: https://www.astro.com/swisseph/swephinfo_e.htm
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.
jayeshmepani/swiss-ephemeris-ffi 适用场景与选型建议
jayeshmepani/swiss-ephemeris-ffi 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.18k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2026 年 03 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「horoscope」 「astronomy」 「jyotish」 「Eclipse」 「ephemeris」 「astrology」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jayeshmepani/swiss-ephemeris-ffi 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jayeshmepani/swiss-ephemeris-ffi 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jayeshmepani/swiss-ephemeris-ffi 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Zodiac Sign Calculator
A Bundle for displaying the zodiac for a Date
Custom horoscope module
PHP library for calculations in Vedic astrology
Calculate sun position, sunlight phases, moon position and lunar phase.
Sun and moon calculations for PHP
统计信息
- 总下载量: 1.18k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 40
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: AGPL-3.0-or-later
- 更新时间: 2026-03-24