PHPackages                             rik0253/moon-phase - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. rik0253/moon-phase

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

rik0253/moon-phase
==================

It gives moon-phases according to date given.

v1.0.4(6y ago)153MITPHP

Since Apr 29Pushed 6y ago1 watchersCompare

[ Source](https://github.com/Rik0253/laravel-moon-phase-package)[ Packagist](https://packagist.org/packages/rik0253/moon-phase)[ RSS](/packages/rik0253-moon-phase/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (6)Used By (0)

A Laravel Package class for calculating the phase of the Moon and you can get the moon rise and set time also.
==============================================================================================================

[](#a-laravel-package-class-for-calculating-the-phase-of-the-moon-and-you-can-get-the-moon-rise-and-set-time-also)

MoonPhase is a PHP class for calculating the phase of the Moon, and other related variables. It is based on [Moontool for Windows](http://www.fourmilab.ch/moontoolw/). Moon Rise/Set time is based on () .

Installation
------------

[](#installation)

composer require rik0253/moon-phase

Usage
-----

[](#usage)

Create an instance of the class by 'new Moonphase('YYYY-MM-DD');', supplying a date for when you want to determine the moon phase (if you don't then the current time will be used). You can then use the following class functions to access the properties of the object:

- `phase()`: get the terminator phase angle as a fraction of a full circle (i.e., 0 to 1). Both 0 and 1 correspond to a New Moon, and 0.5 corresponds to a Full Moon.
- `getMoonData('illumination')`: get the illuminated fraction of the Moon (0 = New, 1 = Full).
- `getMoonData('age')`: get the age of the Moon, in days.
- `getMoonData('distance')`: get the distance of the Moon from the centre of the Earth (kilometres).
- `getMoonData('diameter')`: get the angular diameter subtended by the Moon as seen by an observer at the centre of the Earth (degrees).
- `getMoonData('sundistance')`: get the distance to the Sun (kilometres).
- `getMoonData('sundiameter')`: get the angular diameter subtended by the Sun as seen by an observer at the centre of the Earth (degrees).
- `getPhaseData('new_moon')`: get the time of the last New Moon (DateTime).
- `getPhaseData('next_new_moon')`: get the time of the next New Moon (DateTime).
- `getPhaseData('full_moon')`: get the time of the Full Moon in the current lunar cycle (DateTime).
- `getPhaseData('next_full_moon')`: get the time of the next Full Moon in the current lunar cycle (DateTime).
- `getPhaseData('first_quarter')`: get the time of the first quarter in the current lunar cycle (DateTime).
- `getPhaseData('next_first_quarter')`: get the time of the next first quarter in the current lunar cycle (DateTime).
- `getPhaseData('last_quarter')`: get the time of the last quarter in the current lunar cycle (DateTime).
- `getPhaseData('next_last_quarter')`: get the time of the next last quarter in the current lunar cycle (DateTime).
- `getPhaseName()`: get the phase name.

New Usage
---------

[](#new-usage)

Now you can get the moon rise and set time in unix timestamp. You just need to access the property of the object:

- `getMoonTimes('latitude','logitude')`: get the time of moon rise and moon set (Unix timestamp).

### Example

[](#example)

```
//create an instance of the class, and use the current time
$moon = new Moonphase('1990-04-21');
$age = round($moon->get('age'), 1);
$stage = $moon->phase() < 0.5 ? 'waxing' : 'waning';
$distance = round($moon->get('distance'), 2);
$next = $moon->getPhaseData('next_new_moon');
$phaseName = $moon->getPhaseName();
echo "The moon is currently $age days old, and is therefore $stage. ";
echo "It is $distance km from the centre of the Earth. ";
echo "The next new moon is at $next.";
//To get the moon rise/set time
$moonTime = getMoonTimes(22.5655,88.3653);
echo "Moon rise at ".date('Y-m-d H:i A',strtotime($moonTime->moonrise));
echo "Moon set at ".date('Y-m-d H:i A',strtotime($moonTime->moonset));

```

Help
----

[](#help)

For bugs/enhancements, feel free to either raise an issue or pull request in GitHub, or [contact me](das.sidd89@gmail.com).

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~3 days

Total

5

Last Release

2198d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/acd1e0f19c37306aaac4a6629e095b9fb788f8e2de7d2610fefcc5bc3645b6f2?d=identicon)[Rik0253](/maintainers/Rik0253)

---

Top Contributors

[![siddhantacn](https://avatars.githubusercontent.com/u/77657114?v=4)](https://github.com/siddhantacn "siddhantacn (8 commits)")

### Embed Badge

![Health badge](/badges/rik0253-moon-phase/health.svg)

```
[![Health](https://phpackages.com/badges/rik0253-moon-phase/health.svg)](https://phpackages.com/packages/rik0253-moon-phase)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
