- How do I install rekalogika/pivot-table in a Laravel project?
- Install it with Composer using composer require rekalogika/pivot-table. Because it is framework-agnostic, you can use it directly in Laravel controllers, services, commands, or jobs without a Laravel-specific service provider. Then define your dimensions and aggregations in your reporting code.
- Does rekalogika/pivot-table work with Laravel, and which Laravel versions are supported?
- Yes, it can be used in Laravel because it is framework-agnostic PHP. There is no Laravel-specific integration described, so Laravel version compatibility is mainly a matter of PHP version and Composer constraints. Check the package's composer.json on Packagist for its PHP requirement and confirm it installs with your Laravel version.
- How do I define row and column dimensions in rekalogika/pivot-table?
- You define row and column dimensions declaratively through the library's API using your tabular records. Each dimension controls how records are grouped across the rows or columns of the resulting cross-tabulation. You then attach aggregation measures to summarize the grouped values.
- What aggregations can I apply to pivot table measures?
- The documented examples include sum, count, average, min, and max. You apply them as summary measures over the records grouped by your row and column dimensions. If those are not enough, the library supports custom aggregators.
- Can I filter and sort the results in rekalogika/pivot-table?
- Yes, the library supports filters and sorting to focus and order pivot results. Filters help narrow the records included before summarization, while sorting controls presentation order. Check the package API documentation for the exact methods and supported sort behavior.
- What format does rekalogika/pivot-table return?
- It returns pivot output as structured arrays. That makes the result easy to pass to JSON responses, Blade views, export jobs, or further PHP processing in Laravel. The package is focused on building the pivot data rather than rendering it.
- Can I extend rekalogika/pivot-table with custom aggregators or data sources?
- Yes, the library is designed to be extended with custom aggregators and data sources. That lets you support domain-specific calculations or adapt the pivot to your application's data layer. You would implement the relevant extension points and wire them into your pivot definition.
- How do I test pivot table code in Laravel?
- Use PHPUnit or Pest to feed small, known datasets into your pivot configuration and assert the exact structured arrays returned. Cover grouping, each aggregation, filters, and sorting with separate test cases. In Laravel feature tests, you can also assert the JSON or view output built from the pivot result.
- Is rekalogika/pivot-table suitable for production reporting dashboards?
- It can be suitable for dashboards and exports when your reporting data fits its row-and-column aggregation model. For large datasets, filter or pre-aggregate in the database and cache expensive pivot results rather than recomputing them on every request. Before relying on it in production, review its release history, test coverage, and maintenance activity.
- What are alternatives to rekalogika/pivot-table, and how do I check whether it is maintained?
- Alternatives include writing conditional aggregate queries directly in SQL, using Laravel's query builder for cross-tab summaries, or moving pivot presentation into spreadsheet tooling. Choose based on whether you need structured arrays in PHP or presentation-layer pivots. To assess maintenance, check the package on Packagist and any linked repository for recent releases, open issues, and test activity.