CakePHP
  • Documentation
    • Bootstrap UI
    • CakePDF
    • Crud
    • Crud Users
    • Crud View
    • CsvView
    • Search
  • Community
    • Help & Support
    • Stack Overflow
    • IRC
    • Slack
CakePHP

B Crud Documentation

Page Contents

  • Search
    • Introduction
    • Setup
      • Installation
      • Controller

Search¶

This listener provides search capabilities for the Crud plugin.

Introduction¶

The Search listener depends on the friendsofcake/search package.

Setup¶

Installation¶

composer require friendsofcake/search

Controller¶

Attach it on the fly in your controllers beforeFilter, this is recommended if you want to attach it only to specific controllers and actions.

<?php
class SamplesController extends AppController
{
  public function beforeFilter(\Cake\Event\EventInterface $event) {
      $this->Crud->addListener('Crud.Search', [
          // Events to listen for and apply search finder to query.
          'enabled' => [
              'Crud.beforeLookup',
              'Crud.beforePaginate'
          ],
          // Search collection to use
          'collection' => 'default'
      ]);

      parent::beforeFilter($event);
  }
}

Attach it using components array, this is recommended if you want to attach it to all controllers, application wide.

<?php
class DemoController extends AppController
{
    public function initialize(): void
    {
        $this->loadComponent('Crud.Crud', [
            'actions' => [
                'index'
            ],
            'listeners' => [
                'Crud.Search'
            ]
        ]);
    }
}

Preface

  • Introduction
  • Installation

Usage

  • Quick Start
  • Configuration
  • Actions
  • Events
  • Event subject
  • Listeners
    • API
    • API Pagination
    • API Query Log
    • JSON API
    • Redirect listener
    • Related Models
    • Search
    • Create your own
  • Creating an Api
  • Unit Testing

Navigation

  • index
  • next |
  • previous |
  • Crud v7 »
  • Listeners »
  • Search
  • Documentation
  • Bootstrap UI
  • CakePDF
  • Crud
  • Crud Users
  • Crud View
  • CsvView
  • Search
  • Help & Support
  • Stack Overflow
  • IRC
  • Slack

© Copyright 2025, Friends of Cake. Last updated on Jun 16, 2025. Created using Sphinx 7.4.7.