PHP code example of development-x / pagination-service-provider

1. Go to this page and download the library: Download development-x/pagination-service-provider library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

development-x / pagination-service-provider example snippets



new \Silex\Application;
$app = new Application();

...

$app->register(new \Pagination\PaginationServiceProvider(), array(
    'paginator.options' => array(
        'offset_pages' => 1,
        'items_per_page' => 10,
        'show_prev_next' => false
    )
));

...

return $app->run();

$query = $app['orm.em']->getEntityRepository('\App\Entity\Entity')->createQueryBuilder('e');

$paginator = $app['paginator']->pagination($query, array());

return $app['twig']->render('layout.twig', array('paginator' => $paginator));