scottbass3 / ory-hydra-bundle
Symfony bundle for the Ory Hydra PSR-18 API client
Package info
github.com/scottbass3/OryHydraBundle
Type:symfony-bundle
pkg:composer/scottbass3/ory-hydra-bundle
Requires
- php: ^8.1
- scottbass3/hydra-client-php-psr-18: ^2.0
- symfony/config: ^6.4 || ^7.0 || ^8.0
- symfony/dependency-injection: ^6.4 || ^7.0 || ^8.0
- symfony/framework-bundle: ^6.4 || ^7.0 || ^8.0
- symfony/http-client: ^6.4 || ^7.0 || ^8.0
- symfony/http-kernel: ^6.4 || ^7.0 || ^8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.89
- phpstan/phpstan: ^2.1
- phpstan/phpstan-phpunit: ^2.0
- phpstan/phpstan-symfony: ^2.0
- phpunit/phpunit: ^10.5 || ^11.5 || ^12.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-13 14:23:31 UTC
README
Symfony bundle for scottbass3/hydra-client-php-psr-18, a PSR-18 client for the Ory Hydra API.
It registers every Hydra API (OAuth2Api, OidcApi, JwkApi, MetadataApi, WellknownApi) as an autowirable
service, sending requests through a Symfony HTTP client.
Requires PHP 8.1+ and Symfony 6.4, 7 or 8.
Installation
composer require scottbass3/ory-hydra-bundle
Applications that do not use Symfony Flex must enable the bundle in config/bundles.php:
return [ // ... Scottbass3\OryHydraBundle\Scottbass3OryHydraBundle::class => ['all' => true], ];
Configuration
# config/packages/scottbass3_ory_hydra.yaml scottbass3_ory_hydra: host: '%env(HYDRA_ADMIN_URL)%'
Usage
use Scottbass3\Hydra\Client\Api\OAuth2Api; use Scottbass3\Hydra\Client\Model\OAuth2LoginRequest; use Scottbass3\Hydra\Client\Model\OAuth2RedirectTo; final class LoginController { public function __construct(private readonly OAuth2Api $oAuth2Api) { } public function __invoke(string $loginChallenge): Response { $loginRequest = $this->oAuth2Api->getOAuth2LoginRequest($loginChallenge); if ($loginRequest instanceof OAuth2RedirectTo) { // The request was already handled (HTTP 410) return new RedirectResponse($loginRequest->getRedirectTo()); } // ... } }
See the documentation for every option, authentication, error handling and the upgrade from 1.x.
License
MIT, see LICENSE.