PHP code example of hefekranz / pagination

1. Go to this page and download the library: Download hefekranz/pagination 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/ */

    

hefekranz / pagination example snippets


    public function getMeSomeCollectionAction(Request $request) {

        $data = $objectRepo->findAll();
        
        $pagination = (new Pagination($objectRepo->count(), $request))->build();
        
        return new JsonResponse([
            "pagination" => $pagination->toArray(),
            "data"       => $data->toArray()
        ]);
    }

        $request = Request::create("/collection","GET",["page" => 2,"limit" => 10]); 
        /** or Request::createFromGlobals() */
        $pagination = (new Pagination($objectRepo->count(), $request))->build();