Search by

scottbass3 / ory-hydra-bundle

scottbass3

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

Statistics

Installs: 237

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v2.0.0 2026-11-13 14:22 UTC

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.