// sdk · Symfony
AstroWay API 用 Symfony バンドル
公式 `astroway/sdk-symfony` on Packagist — `astroway/sdk` 上のバンドル。Symfony Flex を介して自動登録、標準の `config/packages/astroway.yaml` を介して構成、任意のコントローラーまたはサービスに注入可能な `Astroway\Astroway` サービスを公開。Symfony 6.4 LTS および 7.x、PHP 8.1+ と互換性がある。
// 01 / install
インストール
composer require astroway/sdk-symfony インポート: use Astroway\Astroway;
レジストリで確認する → astroway/sdk-symfony
// 02 / highlights
特長
- Symfony Flex 自動登録
- 注入可能な Astroway サービス
- 標準の config/packages/astroway.yaml
- 環境によって駆動される API キー
- Symfony 6.4 LTS + 7.x
// 03 / first request
最初のリクエスト
<?php
// config/packages/astroway.yaml
// astroway:
// api_key: '%env(ASTROWAY_API_KEY)%'
use Astroway\Astroway;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Attribute\Route;
final class ChartController extends AbstractController
{
public function __construct(private readonly Astroway $astroway) {}
#[Route('/chart')]
public function chart(): JsonResponse
{
$chart = $this->astroway->post('/chart', body: [
'date' => '1990-07-14',
'time' => '14:30:00',
'timezoneOffset' => 3,
'latitude' => 50.4501,
'longitude' => 30.5234,
'houseSystem' => 'P',
]);
return $this->json($chart);
}
} Symfonyを始める
月額10,000クレジットを無料で利用可能。Open-source SDKで、OpenAPI 3.1から自動生成され、常にバックエンドと同期しています。