Download the PHP package sebastiansulinski/php-paginator without Composer
On this page you can find all versions of the php package sebastiansulinski/php-paginator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sebastiansulinski/php-paginator
More information about sebastiansulinski/php-paginator
Files in sebastiansulinski/php-paginator
Package php-paginator
Short Description Framework agnostic PHP Pagination component
License MIT
Informations about the package php-paginator
Framework agnostic PHP Pagination component
Light weight, easy drop-in pagination component for PHP 8 applications.
Installation
Structure
The component consist of 2 main classes:
-
Pagination
- class, to which you pass- instance of a
SSD\Paginator\Request
or, if your project already makes use of\Illuminate\Http\Request
, you can pass instance of it instead. - total number of records
- number of records per page
- string key representing the query string parameter associated with the current page
- instance of a
-
Paginator
- a parent class for any implementations that return the html structure of a pagination. Its constructor takes 2 arguments:- instance of
Pagination
- records for a given page as instance of
SSD\Paginator\Collection
orIlluminate\Support\Collection
- instance of
Package comes with one implementation of Paginator
:
VueSelectPaginator
The VueSelectPaginator
returns the following structure when render()
method is called on its instance (all entities are decoded for clarity):
And to support this implementation, there is a VueJs
component that ships with this package - you'll find it under resources/src/js/components/SsdPaginator
:
To create your own implementations of Paginator
all you have to do is to provide implementation of the html()
method, which should return the html structure of your pagination layout.
Styling
SsdPaginator comes pre-formatted using tailwindcss v3, but you can replace its structure using the available slot and apply your own styling as required.
Usage
Displaying records and pagination
Custom pagination structure
If you don't want to use Paginator
class implementation, the Pagination
class has all necessary methods to allow you put together pagination structure directly in your view, for instance to display list of all pages as clickable numbers with current page highlighted using class="active"
, you could do something like: