定制 lyyteam/huaxia-lunar-calendar 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lyyteam/huaxia-lunar-calendar

Composer 安装命令:

composer require lyyteam/huaxia-lunar-calendar

包简介

面向 PHP 8 的专业中国历法库:公历/农历/佛历/道历、24 节气(寿星天文历秒级)、四柱八字、大运流年、真太阳时与法定假日,零框架依赖,适用于 ThinkPHP/Laravel/任意 PHP 项目

README 文档

README

面向 PHP 8+ 的专业中国历法计算库。基于寿星天文历实现秒级节气,支持四柱八字、大运流年、真太阳时校正及法定假日查询,零框架依赖、零第三方 Composer 依赖,可嵌入 ThinkPHP、Laravel、Symfony 或任意 PHP 应用。

Tests PHP License

特性

  • 历法互转:公历、农历、佛历、道历
  • 节气精确:寿星天文历 ShouXingUtil,交接时刻秒级
  • 八字命理:四柱 EightChar、大运 Yun / DaYun、流年 LiuNian、流月 LiuYue
  • 流派支持:晚子时 sect1/2、起运 sect1/2 可分离配置
  • 真太阳时:经度校正 + 同源均时差 + 1986–1991 夏令时
  • 民俗辅助:法定假日、三伏数九、星座、城市经度库
  • 专业验证:2424 项节气双锁、5600+ 属性断言、HKO 外部对照,详见 ACCURACY.md

源码仓库: https://github.com/lyyteam/huaxia-lunar-calendar

安装

composer require lyyteam/huaxia-lunar-calendar:^1.0

尚未发布到 Packagist 时,可添加 VCS 仓库:

{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/lyyteam/huaxia-lunar-calendar"
        }
    ],
    "require": {
        "lyyteam/huaxia-lunar-calendar": "^1.0"
    }
}

快速开始

<?php
declare(strict_types=1);

require __DIR__ . '/vendor/autoload.php';

use Lyyteam\HuaxiaLunar\Calendar;
use Lyyteam\HuaxiaLunar\Solar;

// 公历 → 农历
$solar = Calendar::solar(2025, 6, 11);
echo $solar->getLunar()->toString();

// 农历 → 公历(闰月用负数,如闰四月为 -4)
$lunar = Calendar::lunar(1986, 4, 21);
echo $lunar->getSolar()->toYmd();

// 四柱八字
$solar = Solar::fromYmdHms(2005, 12, 23, 8, 37, 0);
$eightChar = $solar->getLunar()->getEightChar();
echo $eightChar->getYear(), $eightChar->getMonth(), $eightChar->getDay(), $eightChar->getTime();

命名空间 Lyyteam\HuaxiaLunar,PSR-4 自动加载。

主要模块

模块 说明
入口 Calendar 快捷创建公历/农历对象
公历 SolarSolarYearSolarMonth 公历日期及推算
农历 LunarLunarYearLunarMonth 农历转换与推算
八字 EightCharYunDaYunLiuNian 四柱、大运、流年流月
节气 JieQi 24 节气查询
工具 Util\ShouXingUtilHolidayUtilTrueSolarUtil 天文历、假日、真太阳时

开发与测试

composer install
composer test

许可证

MIT License

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固