I have been following tutorials, and all instructions show it\'s done the exact same way, but it doesn\'t seem to work in Symfony 4. Is there something I\'m overlooking or i
You have to extend Controller
instead of AbstractController
class:
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class MyController extends Controller
{
public function myAction()
{
$paginator = $this->get('knp_paginator');
or better leave AbstractController
and inject knp_paginator
service into your action:
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Knp\Component\Pager\PaginatorInterface;
class MyController extends AbstractController
{
public function myAction(PaginatorInterface $paginator)
{
$paginator->paginate()...
}