- How do I install reinink/remember-query-strings?
- Install it with Composer using composer require reinink/remember-query-strings. The package is designed as a drop-in Laravel middleware, so after Composer finishes you register the middleware and it works with your existing session configuration. No service provider or config publish step is required for basic use.
- Where should I register the RememberQueryStrings middleware?
- Register the package middleware in your HTTP kernel or bootstrap/app.php depending on your Laravel version. For older Laravel apps, add it to the web middleware group in app/Http/Kernel.php; for Laravel 11-style apps, append it to the web group in bootstrap/app.php. Place it within the web group so the session is available when it runs.
- Does this package support Laravel 10 and Laravel 11?
- The package relies on standard Laravel middleware and session features, so it fits Laravel versions that support those APIs. Because it is a small, pre-1.0 package, check the composer.json illuminate constraints for your exact Laravel release before adopting it. Confirm compatibility in a branch with your app's middleware stack.
- How does it remember query strings per page?
- It stores the last query string in the session keyed by the request path, so /admin/users and /admin/orders remember their own filters independently. When a request arrives at a bare path with no query string, the middleware redirects to the stored full URL. This avoids one page's filters leaking into another page.
- Will it keep table filters, sorting, and pagination?
- Yes, this is the primary use case. When a user applies a filter, changes sort order, or moves to page 3, the query string is saved for that path. Returning to the bare URL later redirects them back to the same filtered and paginated view. It is especially useful for admin tables and report screens.
- What session driver does this package require?
- It uses Laravel's session driver, so it works with any driver that persists session data for the user, including file, database, redis, and cookie sessions. There is no separate storage layer. For stateless API routes or guards without sessions, the middleware has nothing to remember and should not be used.
- Can I exclude certain routes from query string remembering?
- The package does not ship a configuration file by default, so route exclusion is typically done by registering the middleware only on the routes or groups where you want the behavior. You can apply it to a specific admin route group instead of the entire web group. If you need finer control, wrap or conditionally register it in your HTTP kernel.
- Do I need to publish a config file for reinink/remember-query-strings?
- No. Zero configuration is the default; install and register the middleware and it works with your session. There is no config file to publish for basic behavior. If you need custom behavior, you would extend or conditionally register the middleware in your application.
- How do I test remembered query strings in Laravel?
- In a Laravel feature test, visit a URL with a query string, then visit the bare URL and assert a redirect to the remembered URL. Use assertRedirect with the full query string. Because the package uses the session, follow Laravel's session testing patterns and use the same session driver in tests.
- Is reinink/remember-query-strings maintained and production-ready?
- It is a small, single-purpose package by Jonathan Reinink. The version line is pre-1.0, so pin the exact version and review the repository before production use. It has no heavy dependencies and zero configuration, which keeps risk low, but you should still test it against your Laravel and session setup.