Skip to content

Commit 4baa612

Browse files
committed
docs: demonstrate chinese astrology and feng shui
This README has no per-domain example sections, so the two new domains go where the others already live: one runnable example file each, listed beside human-design.php and forecast.php. Both were run against the live API before committing, so the printed field paths are the real ones. The breadth prose outside the DOMAINS markers is hand-written and had gone stale in the same way it did in the other SDKs.
1 parent 84599dc commit 4baa612

4 files changed

Lines changed: 146 additions & 4 deletions

File tree

AGENTS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# roxyapi/sdk - Agent Guide
22

3-
PHP SDK for RoxyAPI. 12+ domains (Western astrology, Vedic astrology, numerology, tarot, human design, forecast, biorhythm, I Ching, crystals, dreams, angel numbers, location) plus utility namespaces (usage, languages). One API key, one Composer package, zero hand-written endpoint code.
3+
PHP SDK for RoxyAPI. 14+ domains (Western astrology, Vedic astrology, forecast, human design, Chinese astrology, feng shui, numerology, tarot, biorhythm, I Ching, crystals, dreams, angel numbers, location) plus utility namespaces (usage, languages). One API key, one Composer package, zero hand-written endpoint code.
44

55
## Install and initialize
66

@@ -54,7 +54,7 @@ $result = $roxy->location->searchCities(q: 'New York');
5454
| `$roxy->languages` | List the response languages accepted by the `lang` query parameter on every i18n-aware endpoint |
5555
<!-- END:DOMAINS -->
5656

57-
160+ endpoints across 12+ product domains plus usage and languages. The table above auto-syncs from `specs/openapi.json` at release time.
57+
209+ endpoints across 14+ product domains plus usage and languages. The table above auto-syncs from `specs/openapi.json` at release time.
5858

5959
## Critical patterns
6060

@@ -112,7 +112,7 @@ $roxy->tarot->getDailyCard(date: '2026-04-22', lang: 'es');
112112
$roxy->numerology->calculateLifePath(year: 1990, month: 1, day: 15, lang: 'hi');
113113
```
114114

115-
Supported: `astrology`, `vedicAstrology`, `numerology`, `tarot`, `biorhythm`, `iching`, `crystals`, `angelNumbers`. English-only: `dreams`, `location`, `usage`, `languages`. To list supported codes at runtime, call `$roxy->languages->listLanguages()`.
115+
Supported: `astrology`, `vedicAstrology`, `forecast`, `humanDesign`, `chineseAstrology`, `fengShui`, `numerology`, `tarot`, `biorhythm`, `iching`, `crystals`, `angelNumbers`. English-only: `dreams`, `location`, `usage`, `languages`. The two Chinese scripts (`zh-Hans`, `zh-Hant`) currently ship on Chinese astrology and feng shui; every other domain answers those codes in English per field. To list supported codes at runtime, call `$roxy->languages->listLanguages()`.
116116

117117
### Error handling
118118

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
[![Packagist](https://img.shields.io/packagist/v/roxyapi/sdk.svg)](https://packagist.org/packages/roxyapi/sdk)
1010
[![PHP Version](https://img.shields.io/packagist/php-v/roxyapi/sdk.svg)](https://packagist.org/packages/roxyapi/sdk)
1111

12-
Official PHP SDK for [RoxyAPI](https://roxyapi.com): natal charts, daily horoscopes, synastry, Vedic kundli, tarot spreads, human design bodygraphs, and transit forecasts across Western and Vedic astrology, numerology, tarot, human design, forecast, biorhythm, I Ching, crystals, dreams, angel numbers, and location geocoding. 160+ endpoints across 12+ domains, one API key, one dependency (Saloon).
12+
Official PHP SDK for [RoxyAPI](https://roxyapi.com): natal charts, daily horoscopes, synastry, Vedic kundli, tarot spreads, human design bodygraphs, and transit forecasts across Western and Vedic astrology, forecast, human design, Chinese astrology, feng shui, numerology, tarot, biorhythm, I Ching, crystals, dreams, angel numbers, and location geocoding. 209+ endpoints across 14+ domains, one API key, one dependency (Saloon).
1313

1414
## Install
1515

@@ -135,6 +135,8 @@ $result = $roxy->astrology->getDailyHoroscope(sign: 'aries');
135135
- `examples/laravel.php` - Laravel service provider snippet
136136
- `examples/human-design.php` - full Human Design bodygraph, prints type, strategy, and profile
137137
- `examples/forecast.php` - cross-domain forecast timeline, prints the event count and a sample event
138+
- `examples/chinese-astrology.php` - BaZi four pillars plus the zodiac sign, prints the pillars and the conventions used
139+
- `examples/feng-shui.php` - Kua number and a flying star natal chart, prints the eight sectors and the nine palaces
138140
- `examples/render-with-ui.html` - server-side fetch + browser render via `@roxyapi/ui`
139141

140142
## Documentation

examples/chinese-astrology.php

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* Chinese astrology example: BaZi four pillars plus the zodiac sign.
7+
*
8+
* ROXY_API_KEY=your-key php examples/chinese-astrology.php
9+
*/
10+
11+
require __DIR__ . '/../vendor/autoload.php';
12+
13+
use RoxyAPI\Sdk\RoxyApiException;
14+
15+
use function RoxyAPI\Sdk\createRoxy;
16+
17+
$apiKey = getenv('ROXY_API_KEY') ?: '';
18+
if ('' === $apiKey) {
19+
fwrite(STDERR, "Set ROXY_API_KEY before running this example.\n");
20+
exit(1);
21+
}
22+
23+
$roxy = createRoxy($apiKey);
24+
25+
try {
26+
// The anchor call of the domain: the rest of it reads off these four pillars.
27+
// timezone is an IANA name, decimal hours (5.5 = IST), or a fixed offset.
28+
// Prefer the IANA name: it resolves to the DST-correct offset for the birth date.
29+
$bazi = $roxy->chineseAstrology->generateBaziChart(
30+
date: '1990-07-04',
31+
time: '10:12:00',
32+
timezone: 'America/New_York',
33+
);
34+
35+
echo "=== BaZi four pillars (1990-07-04 10:12 America/New_York) ===\n";
36+
foreach ($bazi['pillars'] ?? [] as $pillar) {
37+
printf(
38+
"%-6s %-10s %s %s / %s %s %s\n",
39+
$pillar['position'] ?? '?',
40+
$pillar['id'] ?? '?',
41+
$pillar['stem']['chinese'] ?? '?',
42+
$pillar['stem']['element'] ?? '?',
43+
$pillar['branch']['chinese'] ?? '?',
44+
$pillar['branch']['animal'] ?? '?',
45+
$pillar['tenGod']['name'] ?? '?',
46+
);
47+
}
48+
echo 'Day Master: ' . ($bazi['dayMaster']['element'] ?? '?')
49+
. ' (' . ($bazi['dayMaster']['polarity'] ?? '?') . ")\n";
50+
51+
// The conventions echo is what lets a caller reproduce a chart drawn elsewhere:
52+
// the three school splits are typed parameters, not hidden defaults.
53+
echo 'Conventions: ' . json_encode($bazi['conventions'] ?? []) . "\n\n";
54+
55+
// The most searched question in the domain. Defaults yearBoundary to
56+
// "lunar-new-year", the folk rule people mean when they say which animal
57+
// they are; pass "li-chun" to match the classical BaZi boundary above.
58+
$sign = $roxy->chineseAstrology->calculateZodiacAnimal(date: '1990-07-04');
59+
60+
echo "=== Chinese zodiac sign ===\n";
61+
echo 'Animal: ' . ($sign['animal']['name'] ?? '?')
62+
. ' (' . ($sign['animal']['element'] ?? '?') . ' ' . ($sign['animal']['polarity'] ?? '?') . ")\n";
63+
echo 'Year boundary used: ' . ($sign['conventions']['yearBoundary'] ?? '?') . "\n";
64+
} catch (RoxyApiException $e) {
65+
fwrite(STDERR, "[{$e->statusCode}] {$e->errorCode}: {$e->error}\n");
66+
exit(3);
67+
}

examples/feng-shui.php

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* Feng shui example: Kua number plus a flying star natal chart.
7+
*
8+
* ROXY_API_KEY=your-key php examples/feng-shui.php
9+
*/
10+
11+
require __DIR__ . '/../vendor/autoload.php';
12+
13+
use RoxyAPI\Sdk\RoxyApiException;
14+
15+
use function RoxyAPI\Sdk\createRoxy;
16+
17+
$apiKey = getenv('ROXY_API_KEY') ?: '';
18+
if ('' === $apiKey) {
19+
fwrite(STDERR, "Set ROXY_API_KEY before running this example.\n");
20+
exit(1);
21+
}
22+
23+
$roxy = createRoxy($apiKey);
24+
25+
try {
26+
// The entry point of the family: one birth date and a gender gives the
27+
// personal directions everything else reads off.
28+
$kua = $roxy->fengShui->calculateKuaNumber(date: '1990-07-04', gender: 'female');
29+
30+
echo "=== Kua number (1990-07-04, female) ===\n";
31+
echo 'Kua ' . ($kua['kua'] ?? '?')
32+
. ', ' . ($kua['group'] ?? '?') . ' group'
33+
. ', trigram ' . ($kua['trigram']['english'] ?? '?') . "\n";
34+
// Chinese years resolve at Li Chun, computed astronomically, so a January or
35+
// early February birth date can belong to the previous solar year.
36+
echo 'Solar year ' . ($kua['solarYear'] ?? '?')
37+
. ' (boundary ' . ($kua['boundaryDate'] ?? '?') . ")\n";
38+
39+
foreach ($kua['sectors'] ?? [] as $sector) {
40+
printf(
41+
" %-10s %-10s %-13s rank %d %s\n",
42+
$sector['direction'] ?? '?',
43+
$sector['starName'] ?? '?',
44+
$sector['nature'] ?? '?',
45+
$sector['rank'] ?? 0,
46+
$sector['domain'] ?? '?',
47+
);
48+
}
49+
echo "\n";
50+
51+
// Period plus facing gives the nine palaces with base, mountain and water stars.
52+
// Send facing (a mountain id like "bing" or a compass label like "S2") or
53+
// facingDegrees, not neither.
54+
$chart = $roxy->fengShui->generateFlyingStarChart(facing: 'S2', period: 9);
55+
56+
echo "=== Flying star natal chart (period 9, facing S2) ===\n";
57+
echo 'Facing ' . ($chart['facing']['label'] ?? '?')
58+
. ', sitting ' . ($chart['sitting']['label'] ?? '?')
59+
. ' - ' . ($chart['structure']['name'] ?? '?') . "\n";
60+
61+
foreach ($chart['palaces'] ?? [] as $palace) {
62+
printf(
63+
" %-10s base %d mountain %d water %d\n",
64+
$palace['palace'] ?? '?',
65+
$palace['base'] ?? 0,
66+
$palace['mountain'] ?? 0,
67+
$palace['water'] ?? 0,
68+
);
69+
}
70+
} catch (RoxyApiException $e) {
71+
fwrite(STDERR, "[{$e->statusCode}] {$e->errorCode}: {$e->error}\n");
72+
exit(3);
73+
}

0 commit comments

Comments
 (0)