Download the PHP package piko/grid without Composer
On this page you can find all versions of the php package piko/grid. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package grid
Short Description A minimal and framework agnostic grid system.
License LGPL-3.0-or-later
Homepage https://github.com/piko-framework/grid
Informations about the package grid
Piko Grid
A minimal, framework-agnostic grid helper for sortable table headers, pagination links, and result summary text.
Installation
Install the package with Composer:
Quick start
Constructor parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
baseRoute |
string |
'' |
Base URI used to generate sort and pagination links (for example: /admin/users or /admin/users?status=active). |
query |
array<string,mixed> |
[] |
Current query parameters to preserve across generated links (sort, filters, etc.). |
countItems |
int |
0 |
Number of items in the current page/result set. |
totalItems |
int |
0 |
Total number of matching items across all pages. |
itemsPerPage |
int |
0 |
Items per page. |
currentPage |
int |
0 |
Current page number (1-based). |
language |
string |
'en' |
Optional language used only when no global Piko\I18n instance is already available. |
Public API
sortColumn(string $columnName, string $label): string
Returns an HTML link for a sortable header.
- If the column is already sorted, direction toggles between
ASCandDESC. - If not sorted yet, it initializes with
ASC. - Existing query parameters are preserved.
paginator(): JasonGrimes\Paginator
Returns a configured paginator instance for the current grid state.
info(): string
Returns localized summary text:
No resultswhen no rows are available.Results {from} to {to} of {total}otherwise.
Query parameter format
Typical generated URLs use:
pagefor paginationsort[column]=ASC|DESCfor sorting
Examples:
?page=2?sort[lastname]=ASC?sort[id]=DESC&page=3
Internationalization
Piko Grid uses piko/i18n for messages.
Built-in translations include:
- English (default source strings)
- French (
src/messages/fr.php)
You can force a language when creating the grid:
Requirements
- PHP
>= 8.0 piko/i18njasongrimes/paginator
When to use / When not to use
Use this library when
- You want a lightweight, framework-agnostic grid helper.
- You prefer explicit query handling (
sort,page, filters) over widget conventions. - You already control rendering in PHP templates and only need sorting links, pagination wiring, and result info.
- You want minimal dependencies and predictable behavior.
Consider a more abstract grid when
- You need built-in column filters, formatters, action columns, or rich cell rendering.
- You want tight integration with ORM/model layers and data providers.
- You need advanced admin features out of the box (AJAX/PJAX updates, bulk actions, complex column configuration).
- Your team prefers convention-heavy components that reduce custom template code.
In short: piko/grid optimizes for simplicity, portability, and control, while higher-level grids (for example, Yii GridView-style components) optimize for batteries-included features.
Quality checks
Run static checks and coding standards:
Or run them separately:
Contributing
Contributions are welcome.
- Fork the repository
- Create a feature/fix branch
- Run quality checks
- Open a pull request
License
LGPL-3.0-or-later. See LICENSE.txt (or package metadata) for details.