<commit_before># CakePHP Search

Search provides a search module for CakePHP applications.

## Requirements

The master branch has the following requirements:

* CakePHP 3.0.0 or greater.
* PHP 5.4.16 or greater.
* SQLite or another database driver that CakePHP can talk to. By default
  DebugKit will use SQLite, if you need to use a different database see the
  Database Configuration section below.

## Installation

* Install the plugin with composer from your CakePHP Project's ROOT directory (where composer.json file is located)
```sh
php composer.phar require FriendsOfCake/search "dev-master"
```

* Load the plugin
```php
Plugin::load('Search');
```

## Usage

* Add a search config method in your table
```php
use Search\Manager;

...

public function searchConfiguration()
{
    $search = new Manager($this);
    $search
    ->value('currency_id', [
        'field' => $this->alias() . '.currency_id'
    ])
    ->like('name', [
        'before' => true,
        'after' => true,
        'field' => [$this->alias() . '.name']
    ]);
    return $search;
}
```

* Add The Behavior in your initialize method
```php
public function initialize(array $config)
{
    ...
    $this->addBehavior('Search.Search');
    ...
}
```

* Example of index controller for a model Country
```php
public function index()
{
    $query = $this->Country
    ->find('search', $this->request->query)
    ->where(['name !=' => null])
    ->order(['Country.id' => 'asc'])
    ->contain([
        'Cities'
    ]);
    $this->set('countries', $this->paginate($query));
}
```

* Then add the component search in the necessary methods (for our example index)
```php
public function index()
{
    $this->loadComponent('Search.Prg');
}
```

* Instead, you can add this in your AppController to enable component in all index methods
```php
public function initialize()
{
    parent::initialize();
    if ($this->request->action === 'index') {
        $this->loadComponent('Search.Prg');
    }
}
```

## Filtering your data
Once you have completed all the setup you can now filter your data by passing
query params in your index method. Using the Country example given above, you
could filter your countries using the following.

`example.com/countries/index?name=gu`

Would filter your list of countries to any country with "gu" in the name. You
might chose to make a `get` form which posts the filter directly to the url, or
create links manually.
<commit_msg>Fix casing in install command.<commit_after># CakePHP Search

Search provides a search module for CakePHP applications.

## Requirements

The master branch has the following requirements:

* CakePHP 3.0.0 or greater.
* PHP 5.4.16 or greater.
* SQLite or another database driver that CakePHP can talk to. By default
  DebugKit will use SQLite, if you need to use a different database see the
  Database Configuration section below.

## Installation

* Install the plugin with composer from your CakePHP Project's ROOT directory (where composer.json file is located)
```sh
php composer.phar require friendsofcake/search "dev-master"
```

* Load the plugin
```php
Plugin::load('Search');
```

## Usage

* Add a search config method in your table
```php
use Search\Manager;

...

public function searchConfiguration()
{
    $search = new Manager($this);
    $search
    ->value('currency_id', [
        'field' => $this->alias() . '.currency_id'
    ])
    ->like('name', [
        'before' => true,
        'after' => true,
        'field' => [$this->alias() . '.name']
    ]);
    return $search;
}
```

* Add The Behavior in your initialize method
```php
public function initialize(array $config)
{
    ...
    $this->addBehavior('Search.Search');
    ...
}
```

* Example of index controller for a model Country
```php
public function index()
{
    $query = $this->Country
    ->find('search', $this->request->query)
    ->where(['name !=' => null])
    ->order(['Country.id' => 'asc'])
    ->contain([
        'Cities'
    ]);
    $this->set('countries', $this->paginate($query));
}
```

* Then add the component search in the necessary methods (for our example index)
```php
public function index()
{
    $this->loadComponent('Search.Prg');
}
```

* Instead, you can add this in your AppController to enable component in all index methods
```php
public function initialize()
{
    parent::initialize();
    if ($this->request->action === 'index') {
        $this->loadComponent('Search.Prg');
    }
}
```

## Filtering your data
Once you have completed all the setup you can now filter your data by passing
query params in your index method. Using the Country example given above, you
could filter your countries using the following.

`example.com/countries/index?name=gu`

Would filter your list of countries to any country with "gu" in the name. You
might chose to make a `get` form which posts the filter directly to the url, or
create links manually.

{'fraction_non_alphanumeric': 0.13130488053910558, 'fraction_numerical': 0.0028588931999183175, 'mean_word_length': 3.5690298507462686, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1579373', 'n_tokens_mistral': 1434, 'n_tokens_neox': 1376, 'n_words': 544}