Retaining and Restoring query strings plugin for CakePHP 3

Installs: 41

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0


v0.5.1 2018-05-09 03:50 UTC

This package is auto-updated.

Last update: 2021-03-29 00:42:14 UTC


Software License Build Status Codecov Latest Stable Version

This plugin provides a component that makes it possible to restore the conditions in the list, search page, etc. even after transitioning to another page.


  • CakePHP 3.x


You can install this plugin into your CakePHP application using composer.

The recommended way to install composer packages is:

composer require elstc/cakephp-restore-query

Add the following line to your application config/bootstrap.php:

use Cake\Core\Plugin;


Retaining query string

Load the component with your controller's initialize method.

class AppController extends Controller
    public function initialize()
        $this->loadComponent('Elastic/RestoreQuery.RestoreQuery', [
            'actions' => ['index', 'search'], // List of actions to record query string

The component automatically saves the Query string for the target action.

Restore saved query string

By creating a link in the template as follows, the component will call the saved query string and redirect to the target page.

    $this->Html->link('link text', [
        'action' => 'index',
        '?' => ['_restore' => true], // NOTE: _restore=true, the component will restore the saved query.

Elastic/RestoreQuery.RestoreQueryComponent Options


List of actions to record the query string.

default: ['index', 'search']


Name of session key for query string saving

default: 'StoredQuerystring'


Name of the query string for restore action.

default: '_restore'


Redirect when restoring the query string.

default: true