Muhammad Usman

Crazy tech lover, endless learner
Home

Strana - Smart Pagination Library for PHP

A framework agnostic, smart pagination library for PHP. Just a few lines of code and fully functional pagination is ready.

Paginate your records with Strana. Strana will slice(limit and offset) these records, generate pagination links for you and reads page number from them, all automatically.

Features:

  • Built-in adapters for Doctrine, Eloquent (Laravel), Pixie, PHP Array and you can do it manually.
  • Readable syntax
  • Add Infinite Scroll with one line
  • It automatically detects which DBAL you are using.
  • Styles automatically with Twitter Bootstrap, Zurb Foundation and most of other CSS frameworks.

Check out the installation instructions and documentation on GitHub.

Install or View on GitHub

Screenshot:

Screenshot

Example

Basically Strana makes it very easy, like the code below:

 
$paginator = $strana->perPage(10)->make($records);

That’s basically it.

Full Usage Example

 
// Make sure you have Composer's autoload file included
require 'vendor/autoload.php'; 

$strana = new \Strana\Paginator();
$records = array(1, 2, 3, :. 100);
$paginator = $strana->perPage(10)->make($records);

// Loop paginated items 
foreach ($paginator as $item) {
    echo $item['field_name'] . '<br>';
}

// Print pagination links
echo '<br><br>;' . $paginator;

There are some advanced options which are documented below. Sold? Let’s install.