Download the PHP package scrnr/pagination without Composer
On this page you can find all versions of the php package scrnr/pagination. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download scrnr/pagination
More information about scrnr/pagination
Files in scrnr/pagination
Package pagination
Short Description Pagination library in PHP
License MIT
Homepage https://github.com/scrnr/pagination-library-php
Informations about the package pagination
PHP Pagination Library
Table Of Contents
- Description
- Installation
- Usage
- Customization Pagination Settings
- Conclusion
- Author
- License
Description :top:
This is a simple and flexible PHP library for creating pagination in your web applications. It allows you to easily paginate large sets of data and display them in smaller, more manageable chunks.
Installation :top:
You can install the library using Composer. Simply add the following lines to your composer.json
file and run composer install
:
Or you can use this command:
Usage :top:
To use the pagination library in your application, you need to include the Composer autoload file and create a new instance. After creating an instance, you can call the getPagination()
method, passing an optional array of options as a parameter. This method to generate a string representation of the pagination links.
Here is an example of usage
Output
In this example, we first include the namespace for the Pagination class. We then require the Composer autoload file, which loads the necessary classes and files for our project. Finally, we create a new instance of the Pagination class and use it to generate pagination.
Customization Pagination Settings :top:
You can customize the pagination settings by passing an array of options to the getPagination()
method. The following options are available:
Option Name | Type | Default | Description |
---|---|---|---|
url |
string | '' |
Represents URL of the page being paginated. This setting is required to ensure that the correct page is displayed. |
uri |
string | '/' |
Represents URI of the page being paginated. This setting is required to ensure that the correct page is displayed. |
showArrowLinks * |
boolean | true |
Determines whether arrows are displayed at the edges of the pagination. These arrows can be used to navigate to the first or last page. |
showDummyLinks * |
boolean | (showArrowLinks === true) ? true : false |
Determines whether dummy links are displayed. When there are many pagination pages and the showArrowLinks option is set to true , the dummy links will be displayed before the arrows links. |
isGetPagination |
boolean | false |
Determines whether pagination information is included in the URL as GET parameters. When this setting is enabled, the pagination information is included in the URL as query parameters (e.g., ?page=2 or ?p=2 ). When this setting is disabled, pagination information will be included in the URL as friendly URLs* (e.g., /page/2 or /p/2 ). |
currentPage |
integer | 1 |
Represents the current page number. This setting is required to ensure that the correct page is highlighted. |
limitItems |
integer | 15 |
Represents the number of items displayed on each page. This setting is required to ensure that the correct number of items are displayed. |
limitPages |
integer | 7 |
Represents the maximum number of pagination links to display. If there are more pages than this setting, the library will automatically limit the number of links displayed. |
totalItems |
integer | 65 |
Represents the total number of items being paginated. This setting is required to calculate the total number of pages. |
id |
string | 'pagination' |
The ID of the pagination element. |
navClass |
string | 'pagination' |
Represents the CSS class for the <nav> tag within tha pagination. |
ulClass |
string | 'pagination__ul' |
Represents the CSS class for the <ul> tag within the pagination. |
liClass |
string | 'pagination__item' |
Represents the CSS class for each <li> tag within the pagination. |
linkClass |
string | 'pagination__link' |
Represents the CSS class for each <a> tag within the pagination. |
activeClass |
string | 'pagination__link active' |
Represents the CSS class for the active page link |
nextClass |
string | 'pagination__link next' |
Represents the CSS class for the next page link. |
prevClass |
string | 'pagination__link previous' |
Represents the CSS class for the previous page link. |
arrowLinkClass |
string | 'pagination__link arrow' |
Represents the CSS class for the arrow elements within the pagination. |
dummyLinkClass |
string | 'pagination__link dummy' |
Represents the CSS class for the dummy link elements within the pagination. |
NOTES
Option Name | NOTE |
---|---|
showArrowLinks |
To display the first and last arrows, the value of the limitPages option must be greater than or equal to 4 . |
showDummyLinks |
To display dummy links, the value of the limitPages option must be greater than or equal to 6 and showArrowLinks must be true . |
Conclusion :top:
The Pagination library is a simple and flexible solution for paginating large datasets. It is easy to use, easy to customize and compatible with any PHP project.
Author :top:
👤 GitHub: scrnr
License :top:
This library is released under the MIT License. Please review the LICENSE file for more information.