// sdk · Symfony
Gói Symfony cho AstroWay API
Chính thức `astroway/sdk-symfony` trên Packagist — một Gói trên `astroway/sdk`. Tự động đăng ký qua Symfony Flex, cấu hình thông qua `config/packages/astroway.yaml` tiêu chuẩn, hiển thị dịch vụ `Astroway\Astroway` tự động kết nối để tiêm vào bất kỳ bộ điều khiển hoặc dịch vụ nào. Tương thích với Symfony 6.4 LTS và 7.x, PHP 8.1+.
// 01 / install
Cài đặt
composer require astroway/sdk-symfony import: use Astroway\Astroway;
Xem trong sổ đăng ký → astroway/sdk-symfony
// 02 / highlights
Điểm nổi bật
- Tự động đăng ký Symfony Flex
- Dịch vụ AstroWay tự động kết nối
- Cấu hình tiêu chuẩn config/packages/astroway.yaml
- api_key dẫn động môi trường
- Symfony 6.4 LTS + 7.x
// 03 / first request
Yêu cầu đầu tiên
<?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);
}
} Bắt đầu với Symfony
10.000 credits miễn phí mỗi tháng. SDK mã nguồn mở, được tạo từ OpenAPI 3.1, luôn đồng bộ với backend.