jayeshmepani/swiss-ephemeris-ffi
PHP 8.3+ FFI wrapper for the Swiss Ephemeris C library. Exposes all 106 public API functions with 1:1 constant/signature parity and zero abstraction. No swetest shelling; outputs verified for parity via PHPUnit against swetest.
public/ to storage/app/swisseph/ for native library publishing aligns with Laravel’s security best practices (non-web-accessible storage).CelestialService) rather than monolithic applications. The package’s singleton behavior and library path flexibility simplify integration but require careful scoping to avoid global state issues.ext-ffi enabled, which may require runtime configuration (e.g., ffi.enable=true in php.ini). This is a hard blocker for shared hosting or legacy environments.libswisseph (e.g., for research) must pre-install libraries and configure paths, adding operational friction.serr strings into Laravel-friendly exceptions (e.g., AstroCalculationException).libswisseph 2.10.3 may lag behind upstream (e.g., v3.0). Teams relying on latest features (e.g., new asteroid data) must manually update binaries, breaking the package’s convenience.php-astro) suffice?libswisseph updates (e.g., v3.0) and rebuild binaries if needed?SwissEphException)?SwissEphFFI::facade()) for dependency injection.composer require).storage/app/swisseph/) to avoid web exposure.php.ini or Docker PHP_INI_SCAN_DIR).PlanetaryPosition).php artisan tinker):
use SwissEph\FFI\SwissEphFFI;
$sweph = new SwissEphFFI();
$sweph->swe_julday(2023, 1, 1, 0, SwissEphFFI::SE_GREG_CAL); // Should not crash.
AppServiceProvider:
public function register() {
$this->app->singleton(SwissEphFFI::class, fn() => new SwissEphFFI());
}
use SwissEph\FFI\SwissEphFFI;
public function horoscope(Request $request, SwissEphFFI $sweph) {
$jd = $sweph->swe_julday(...);
// ...
}
php artisan vendor:publish --provider="SwissEph\FFI\SwissEphServiceProvider" --tag="ephe-files"
storage/app/swisseph/..env:
SWISSEPH_LIBRARY_PATH=/custom/path/to/libswisseph.so
$sweph = new SwissEphFFI('/custom/path/to/libswisseph.so');
php-sweph CLI calls).How can I help you explore Laravel packages today?