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
The installation works with Composer by running the following command.
composer require intervention/zodiacAlthough 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.
Read the full documentation for this library.
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);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); // .6This library is developed and maintained by Oliver Vogel
Thanks to the community of contributors who have helped to improve this project.
Intervention Zodiac is licensed under the MIT License.