Zodiac Sign Calculator

Maintainers

Package info

github.com/Intervention/zodiac

Homepage

pkg:composer/intervention/zodiac

Statistics

Installs: 193 597

Dependents: 0

Suggesters: 0

Stars: 58

Open Issues: 0

7.0.0 2026-04-10 05:31 UTC

README

Latest Version Tests Monthly Downloads Support me on Ko-fi

Intervention Zodiac is a astrological calculator for PHP 8.2+ that resolves Western and Chinese zodiac signs from various data types.

  • Fluent interface to calculate zodiac signs
  • Support for western and chinese astrology
  • Framework-agnostic

Installation

The installation works with Composer by running the following command.

composer require intervention/zodiac

Although the library is framework agnostic it comes with a service provider for the Laravel Framework. Which will be discovered automatically and registers the calculator into your installation.

Getting Started

Read the full documentation for this library.

Code Examples

Calculator

use Intervention\Zodiac\Calculator;
use Intervention\Zodiac\Astrology;
use DateTime;

// create calculator with astrology
$calculator = new Calculator(Astrology::WESTERN);

// calculate various date formats
$sign = $calculator->calculate('2001-01-01');
$sign = $calculator->calculate('first day of june 2014');
$sign = $calculator->calculate('2018-06-15 12:34:00');
$sign = $calculator->calculate(new DateTime('2001-01-01'));
$sign = $calculator->calculate(228268800);
$sign = $calculator->calculate('228268800');

// override the default astrology
$sign = $calculator->calculate('2001-01-01', Astrology::CHINESE);

Sign

use Intervention\Zodiac\Sign;
use Intervention\Zodiac\Chinese\Sign as ChineseSign;
use Intervention\Zodiac\Western\Sign as WesternSign;
use DateTime;

// parse signs directly
$sign = Sign::fromString('2000-01-01');
$sign = Sign::fromString('first day of june 2014');
$sign = Sign::fromDate(new DateTime('2001-01-01'));
$sign = Sign::fromUnix(228268800);
$sign = Sign::fromUnix('228268800');

// parse western signs directly
$sign = WesternSign::fromString('2000-01-01');

// parse chinese signs directly
$sign = ChineseSign::fromString('2000-01-01');

// sign methods
$name = $sign->name(); // 'gemini'
$html = $sign->html(); // '♊︎'
$localized = $sign->localize('fr')->name(); // Gémeaux
$compatibility = $sign->compatibility($sign); // .6

Authors

This library is developed and maintained by Oliver Vogel

Thanks to the community of contributors who have helped to improve this project.

License

Intervention Zodiac is licensed under the MIT License.