---
title: "Retrieving Views"
package: "PagerfantaBundle"
version: "5.x"
canonical_url: "https://www.babdev.com/open-source/packages/pagerfantabundle/docs/5.x/retrieving-views"
package_supported: true
version_released: false
notice:
  - "Version 5.x of PagerfantaBundle has not been released yet. Its API may change before release."
---
# Retrieving Views

You can access the Pagerfanta views through the `pagerfanta.view_factory` service, which is a `Pagerfanta\View\ViewFactoryInterface` instance. This is useful if your application does not use Twig but you still want to use Pagerfanta views for rendering pagination lists.

```php
<?php

namespace App\Service;

use Pagerfanta\PagerfantaInterface;
use Pagerfanta\RouteGenerator\RouteGeneratorFactoryInterface;
use Pagerfanta\View\ViewFactoryInterface;

final class PagerfantaService
{
    public function __construct(
        private readonly ViewFactoryInterface $viewFactory,
        private readonly RouteGeneratorFactoryInterface $routeGeneratorFactory,
    ) {
    }

    public function render(PagerfantaInterface $pagerfanta, string $view, array $options = []): string
    {
        return $this->viewFactory->get($view)->render($pagerfanta, $this->routeGeneratorFactory->create($options), $options);
    }
}
```
