subdomainto / symfony-bundle
Symfony bundle for the subdomain.to custom domains API with an autowired client, configuration, and signed webhook attributes.
Package info
github.com/subdomain-to/symfony-bundle
Type:symfony-bundle
pkg:composer/subdomainto/symfony-bundle
Requires
- php: ^8.1
- nyholm/psr7: ^1.8
- subdomainto/sdk: ^1.0
- symfony/config: ^6.4 || ^7.4 || ^8.0
- symfony/dependency-injection: ^6.4 || ^7.4 || ^8.0
- symfony/framework-bundle: ^6.4 || ^7.4 || ^8.0
- symfony/http-client: ^6.4 || ^7.4 || ^8.0
- symfony/http-kernel: ^6.4 || ^7.4 || ^8.0
Requires (Dev)
- phpunit/phpunit: ^10.5 || ^11.0 || ^12.0
- symfony/yaml: ^6.4 || ^7.4 || ^8.0
README
subdomainto/symfony-bundle integrates the subdomain.to custom domains API with Symfony. It configures the typed PHP client, enables autowiring, supports environment-based credentials, and verifies signed webhooks through a controller attribute.
The bundle supports Symfony 6.4, 7.4, and 8.x on PHP 8.1 or later.
Installation
composer require subdomainto/symfony-bundle
Symfony Flex normally registers the bundle. Configure the API client and webhook verifier:
# config/packages/subdomain_to.yaml subdomain_to: api_key: '%env(SUBDOMAINTO_API_KEY)%' webhook_secret: '%env(SUBDOMAINTO_WEBHOOK_SECRET)%' webhook_tolerance: 300
Autowire the custom domains client
use SubdomainTo\Client; use SubdomainTo\Model\Domain; final class ConnectCustomerDomain { public function __construct(private Client $subdomainTo) {} public function __invoke(string $customerId, string $hostname): Domain { return $this->subdomainTo->domains()->create( $hostname, $customerId.'-domain', ); } }
The client exposes typed resources for destinations, domains, DNS and TLS lifecycle status, webhooks, widget sessions, usage, and billing.
Verify a webhook controller
use SubdomainTo\Symfony\Attribute\VerifySubdomainToWebhook; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; #[VerifySubdomainToWebhook] public function webhook(Request $request): Response { $event = $request->attributes->get('subdomainto_event'); return new Response(status: 204); }
The attribute triggers verification of the untouched request body, SubdomainTo-Signature, HMAC signature, and timestamp before the controller runs.
Documentation
Read the Symfony SDK guide, browse the custom domains API documentation, or report an issue in the GitHub repository.
License
MIT