jayeshmepani/panchang-core

Authentic Vedic Panchanga calculation engine powered by the JPL Moshier Ephemeris FFI wrapper

Maintainers

Package info

github.com/jayeshmepani/panchang-core

pkg:composer/jayeshmepani/panchang-core

Statistics

Installs: 13

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

7.0.1 2026-05-30 04:43 UTC

This package is auto-updated.

Last update: 2026-05-30 04:55:25 UTC


README

Latest Version on Packagist Total Downloads PHP Version Require License: MIT

High-precision Hindu Panchang calculation engine for PHP 8.3+, powered by the JPL Moshier Ephemeris FFI wrapper.

It calculates Panchanga limbs, festivals, Muhurta windows, Karmakala timings, Chogadiya, Hora, Lagna tables, direction/Vaasa checks, eclipse visibility, and localized JSON outputs.

Highlights

  • Panchanga: Tithi, Vara, Nakshatra, Yoga, Karana
  • Muhurta and Karmakala: Abhijit, Brahma Muhurta, Dur Muhurta, Nishita, Vijaya, Godhuli, Pradosha, Varjyam, Amrita Kaal
  • Daily tables: Chogadiya, Hora, Prahara, 30 Muhurtas, Lagna intervals
  • Festival engine: 391 definitions with tradition and regional handling
  • Vaasa and direction checks: Disha Shool, Rahu Vaasa, Chandra Vaasa, Shiva Vaasa, Agni Vaasa, Yogini Vaasa
  • Locales: English, Hindi, Gujarati
  • Calendar types: Amanta and Purnimanta
  • Works standalone or inside Laravel

Install

composer require jayeshmepani/panchang-core

Requirements:

  • PHP 8.3+
  • PHP FFI extension enabled
  • jayeshmepani/jpl-moshier-ephemeris-php
  • nesbot/carbon

Enable FFI in php.ini:

extension=ffi
ffi.enable=1

For CLI verification:

php -r "echo extension_loaded('ffi') ? 'FFI loaded\n' : 'FFI not loaded\n';"

Quick Usage

<?php

require 'vendor/autoload.php';

use Carbon\CarbonImmutable;
use JayeshMepani\PanchangCore\Traits\CliBootstrap;

CliBootstrap::init(__DIR__);

$panchang = CliBootstrap::makePanchangService();

$details = $panchang->getDayDetails(
    date: CarbonImmutable::parse('2026-05-29'),
    lat: 23.2472446,
    lon: 69.668339,
    tz: 'Asia/Kolkata'
);

echo $details['Current_Tithi_At_Input_Now']['name'] . PHP_EOL;
echo $details['Tithi_At_Sunrise']['name'] . PHP_EOL;
echo $details['Current_Karana_At_Input_Now']['name'] . PHP_EOL;
echo $details['Nakshatra']['name'] . PHP_EOL;

Laravel facade usage:

use Carbon\CarbonImmutable;
use JayeshMepani\PanchangCore\Facades\Panchang;

$details = Panchang::getDayDetails(
    date: CarbonImmutable::parse('2026-05-29'),
    lat: 23.2472446,
    lon: 69.668339,
    tz: 'Asia/Kolkata'
);

$festivals = $details['Festivals'];

Important Output Semantics

  • Tithi and Karana are sunrise-based compatibility fields.
  • Use Current_Tithi_At_Input_Now, Current_Nakshatra_At_Input_Now, Current_Yoga_At_Input_Now, and Current_Karana_At_Input_Now for runtime/current values.
  • Use Tithi_At_Sunrise, Nakshatra_At_Sunrise, and Karana_At_Sunrise when sunrise semantics are required explicitly.
  • Brahma_Muhurta uses the dynamic night-muhurta convention by default: previous sunset to sunrise divided into 15 night Muhurtas.
  • The fixed 48-minute Brahma Muhurta convention is preserved under Brahma_Muhurta.fixed_48_minute_convention.
  • Amrita_Kaal is calculated independently from nakshatra-specific Amrita ghati offsets, not from Varjyam.
  • Lagna_Full_Day includes partial intervals that overlap the sunrise-to-next-sunrise Panchang day.
  • Chandra_Vaasa uses Moon-rashi direction as the primary field and preserves the older nakshatra-pada Vaasa under nakshatra_pada_vaasa.
  • Nakshatra-derived current windows such as Anandadi Yoga, Amritadi Yoga, and nakshatra-pada Chandra Vaasa are selected from the calculation time, not blindly from the first sunrise window.
  • Eclipse output separates global classification from local visibility classification with global_eclipse_type and local_eclipse_type.
  • Day_Types.apparent_solar_noon is the astronomical solar transit.
  • Abhijit_Muhurta.daylight_midpoint is the sunrise-to-sunset midpoint used for Abhijit calculation.

CLI Exporters

php scripts/panchang_today.php
php scripts/panchang_month_output.php 2026 5 > month_2026_05.json
php scripts/panchang_festivals.php 2026
php scripts/panchang_eclipses.php 2026 2032

Notes:

  • panchang_today.php writes today_panchang.json and prints status text.
  • panchang_month_output.php prints JSON to stdout. Without arguments, it generates the current month.
  • panchang_festivals.php writes festivals_YYYY.json.
  • panchang_eclipses.php writes eclipses_YYYY_YYYY.json.
  • Use PANCHANG_LOCALE=en|hi|gu and PANCHANG_CALENDAR_TYPE=amanta|purnimanta for variants.

Documentation

Development

composer install
composer test
composer phpstan
composer lint:check

License

MIT. See LICENSE.

Credits

Built by Jayesh Mepani.