turbolabit / paginatorbundle
Installs: 384
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- symfony/translation: @stable
Requires (Dev)
- phpunit/phpunit: @stable
- symfony/dotenv: @stable
- symfony/framework-bundle: @stable
- symfony/yaml: @stable
This package is auto-updated.
Last update: 2025-06-13 11:44:04 UTC
README
A simple Symfony bundle to render the "classic" pagination element.
It also works without Symfony, as a plain PHP object.
📦 Install it with composer
symfony composer require turbolabit/paginatorbundle:dev-main
🏗️ Use it
src/Service/Paginator.php
<?php namespace App\Service; use \TurboLabIt\PaginatorBundle\Service\Paginator as BasePaginator; class Paginator extends BasePaginator { protected string $pageParam = 'p'; protected int $slotNum = 5; }
src/Controller/ListingController.php
<?php namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; use App\Service\Paginator; class ListingController extends AbstractController { protected Request $request; public function __construct(RequestStack $requestStack, protected Paginator $paginator) { $this->request = $requestStack->getCurrentRequest(); } #[Route('/{categorySlug}/', name: 'app_listing', priority: -99)] public function listing(string $categorySlug) : Response { $currentPage = $this->request->get('p') ?? 1; $totalPages = 99; $oPages = $this->paginator ->setBaseUrl('/' . $categorySlug . '/') ->build($currentPage, $totalPages); return $this->render('listing.html.twig', [ 'page' => $currentPage, 'Pages' => $oPages ]); } }
🧪 Test it
bash scripts/symfony-bundle-tester.sh