- What is hyperf/paginator and how does it relate to Laravel pagination?
- hyperf/paginator is a pagination package for Hyperf applications that follows Laravel-style pagination concepts. It provides length-aware and simple paginators, supports array and query-result pagination, and can generate URLs, query strings, and navigation views. It is not Laravel itself, but it gives Hyperf developers a familiar paginator API and behavior.
- How do I install hyperf/paginator in a Hyperf application?
- Install it with Composer by running composer require hyperf/paginator in your Hyperf project. After installation, configure the package according to your Hyperf application structure and any page-size or view settings you need. Then use its paginator classes or helpers in your controllers or services.
- Does hyperf/paginator support Laravel or specific Laravel versions?
- hyperf/paginator is not a Laravel package and does not target Laravel version constraints; it targets Hyperf applications. Laravel applications should use Laravel's built-in paginator for version-appropriate behavior. Use hyperf/paginator when you want Laravel-style pagination inside a Hyperf project.
- What is the difference between length-aware and simple pagination in hyperf/paginator?
- A length-aware paginator typically knows the total number of records and can show total pages or result counts. A simple paginator avoids that total count and is useful when you only need next and previous navigation. hyperf/paginator supports both styles so you can choose based on performance and UI needs.
- Can I paginate plain arrays with hyperf/paginator?
- Yes, the package supports array pagination in addition to query-result pagination. This is useful for paginating in-memory lists or data that has already been fetched. You can apply the same page-size and navigation concepts to array-backed results.
- Can I paginate database query results with hyperf/paginator?
- Yes, hyperf/paginator supports paginating query results, which is the common use case for database-backed lists. You can use it to split large result sets into pages and generate navigation links. For production queries, combine pagination with appropriate ordering and indexing.
- How do I customize the page size in hyperf/paginator?
- The package supports customizable page sizes, so you can set how many items appear per page. You can typically provide the page size when building the paginator or through your application configuration. This lets you offer different page sizes for different endpoints or user preferences.
- How does hyperf/paginator generate pagination URLs and query strings?
- hyperf/paginator can generate pagination URLs and query strings so navigation links preserve the current request context. This helps keep filters, search terms, and other query parameters intact when moving between pages. You can use the generated URLs when rendering links or building API pagination metadata.
- Can I render pagination navigation views with hyperf/paginator?
- Yes, the package supports view rendering for pagination navigation, similar to Laravel-style pagination views. You can render consistent next, previous, and page links in your Hyperf templates. If needed, you can customize the view output to match your application's design.
- How should I test and maintain hyperf/paginator in production?
- Test pagination boundaries such as the first page, last page, empty results, and custom page sizes in your Hyperf application. In production, pin the Composer version and review package updates or repository activity for compatibility with your Hyperf version. Also verify that query-string preservation and rendered navigation links work correctly behind your web server or API gateway. For alternatives, Laravel applications should use Laravel's built-in paginator, while Hyperf projects can compare this package with other Hyperf pagination options.