PHPackages                             locomotivemtl/charcoal-search - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. locomotivemtl/charcoal-search

ActiveLibrary[Search &amp; Filtering](/categories/search)

locomotivemtl/charcoal-search
=============================

Charcoal Search Engine tools and utilities

0.2.3.1(5y ago)01.5k↓100%11MITPHPPHP &gt;=5.6.0 || &gt;=7.0CI failing

Since Oct 31Pushed 2y ago13 watchersCompare

[ Source](https://github.com/locomotivemtl/charcoal-search)[ Packagist](https://packagist.org/packages/locomotivemtl/charcoal-search)[ Docs](https://charcoal.locomotive.ca)[ RSS](/packages/locomotivemtl-charcoal-search/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (2)Dependencies (8)Versions (9)Used By (1)

Charcoal Search
===============

[](#charcoal-search)

This module has all the tools and utilities to create a quick search engine for a Charcoal-based projects.

It features a very customizable search engines / search configuration that allows to search in SQL database tables, Charcoal Models or do custom search.

Table of content
================

[](#table-of-content)

- [How to install](#how-to-install)
    - [Dependencies](#dependencies)
- [Example usage](#example-usage)
- [Constructor options](#constructor-options)
- [Search config](#search-config)
- [Search types](#search-types)
    - [Custom search](#custom-search)
        - Custom options
    - [Model search](#model-search)
    - [Table search](#table-search)
- [Search log](#search-log)
- [Charcoal-admin integration](#charcioal-admin-integration)
- [Development](#development)
    - [Development dependencies](#development-dependencies)
    - [Coding Style](#coding-style)
    - [Authors](#authors)
    - [Changelog](#changelog)

How to install
==============

[](#how-to-install)

The preferred (and only supported) way of installing *charcoal-search* is with **composer**:

```
★ composer require locomotivemtl/charcoal-search
```

Dependencies
------------

[](#dependencies)

- [`PHP 5.5+`](http://php.net)
- [`locomotivemtl/charcoal-core`](https://github.com/locomotivemtl/charcoal-core)
- [`locomotivemtl/charcoal-base`](https://github.com/locomotivemtl/charcoal-base)

Example usage
=============

[](#example-usage)

```
use \Charcoal\Search\SearchRunner;

use \Foo\Bar\CustomObject;

$searchRunner = new SearchRunner([
    'search_config' => [
        'ident'    => 'my-custom-search',
        'searches' => [
            'foo'  => new CustomSearch([
                'logger'   => $logger
                'callback' => function($keyword) {

                }
            ])
        ]
    ],
    'model_factory' => $modelFactory,
    'logger'        => $logger
]);

// The results are an array like `['foo'=>[...], 'bar'=>[...]]`
$results = $searchRunner->search($keyword);

// Access log
$log = $searchRunner->searchLog();

// Differed access to results
$results = $searchRunner->results();
```

Constructor options
===================

[](#constructor-options)

The `SearchRunner` is instanciated with a single parameter, which contains the constructor options and class dependencies:

IdentTypeDescription**logger**`\Psr\Log\LoggerInterface`A PSR-3 logger.**model\_factory**`\Charcoal\Factory\FactoryInterface`A factory to create objects (and logs).**search\_config**`array`A [search config](#search-config) objectSearch config
-------------

[](#search-config)

The search config object contains the search ident as well as the various searches to run on objects.

IdentTypeDescription**ident**`string`**searches**`array`The various searches to perform.Search types
============

[](#search-types)

Available search types, which are defined in the search config's **searches**:

- `custom`
- `table` (todo)
- `model` (todo)

Custom search
-------------

[](#custom-search)

The `custom` search defines a callback function. This can either be a callable (a method or an object with an `__invoke` method) or a string (which will attempt to call the function of matching name on the Search Runner object).

The callback method must have the following signature: `array callback(string $keyword);`

### Custom options

[](#custom-options)

IdentTypeDescription**callback**`callback`Optional callback to defer searching to.Table search
------------

[](#table-search)

The `table` search is still **todo**.

Model search
------------

[](#model-search)

The `model` search is still **todo**.

Search log
==========

[](#search-log)

Every search is automatically logged to (SQL) storage.

Charcoal-admin integration
==========================

[](#charcoal-admin-integration)

The search-log object comes by default with full metadata to display in charcoal-admin. Visit at \[\[your-site.com\]\]/admin/object/collection?obj-type=charcoal/search/search-log.

There are 2 widgets also available to visualize logs:

- `charcoal/admin/widget/search/no-results-search`
- `charcoal/admin/widget/search/top-search`

Development
===========

[](#development)

To install the development environment:

```
★ composer install --prefer-source
```

To run the scripts (phplint, phpcs and phpunit):

```
★ composer test
```

Development dependencies
------------------------

[](#development-dependencies)

- `phpunit/phpunit`
- `squizlabs/php_codesniffer`
- `satooshi/php-coveralls`

Continuous Integration
----------------------

[](#continuous-integration)

ServiceBadgeDescription[Travis](https://travis-ci.org/locomotivemtl/charcoal-search)[![Build Status](https://camo.githubusercontent.com/7b3607c5e9873e8cb4ee286e0c6d5b92aaa8541b888bfb2d0ed3f1ef9934d610/68747470733a2f2f7472617669732d63692e6f72672f6c6f636f6d6f746976656d746c2f63686172636f616c2d7365617263682e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/locomotivemtl/charcoal-search)Runs code sniff check and unit tests. Auto-generates API documentation.[Scrutinizer](https://scrutinizer-ci.com/g/locomotivemtl/charcoal-search/)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/c4343b3ce4d42ceed0408f3f0cba63a389f4bd0ca104a80b95975d78b6a3c43c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6c6f636f6d6f746976656d746c2f63686172636f616c2d7365617263682f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/locomotivemtl/charcoal-search/?branch=master)Code quality checker. Also validates API documentation quality.[Coveralls](https://coveralls.io/github/locomotivemtl/charcoal-search)[![Coverage Status](https://camo.githubusercontent.com/7bcd3b90ac45eab5beb25e99db5e0b3df37e7950de4b96cda7d007a641635a3b/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6c6f636f6d6f746976656d746c2f63686172636f616c2d7365617263682f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/locomotivemtl/charcoal-search?branch=master)Unit Tests code coverage.[Sensiolabs](https://insight.sensiolabs.com/projects/d7fe2c2a-5624-4e4c-9de2-4bc4c5f4c965)[![SensioLabsInsight](https://camo.githubusercontent.com/ffd53a9c63fb230c4fe4a50f53a80014b6842e3926e38aab8c840a8e155834a9/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f64376665326332612d353632342d346534632d396465322d3462633463356634633936352f6d696e692e706e67)](https://insight.sensiolabs.com/projects/d7fe2c2a-5624-4e4c-9de2-4bc4c5f4c965)Another code quality checker, focused on PHP.Coding Style
------------

[](#coding-style)

All Charcoal modules follow the same coding style and `charcoal-search` is no exception. For PHP:

- [*PSR-1*](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md)
- [*PSR-2*](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)
- [*PSR-4*](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md), autoloading is therefore provided by *Composer*
- [*phpDocumentor*](http://phpdoc.org/)
- Read the [phpcs.xml](phpcs.xml) file for all the details on code style.

> Coding style validation / enforcement can be performed with `composer phpcs`. An auto-fixer is also available with `composer phpcbf`.

Authors
-------

[](#authors)

- Mathieu Ducharme

Changelog
---------

[](#changelog)

- Unreleased

**The MIT License (MIT)**

*Copyright © 2016 Locomotive inc.*

> See [Authors](#authors).

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 56.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~301 days

Recently: every ~357 days

Total

6

Last Release

1972d ago

PHP version history (3 changes)0.1PHP &gt;=5.5.0

0.2PHP &gt;=5.6.0

0.2.3PHP &gt;=5.6.0 || &gt;=7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/cfb071c0ff7ce9500c528a003a2c53124248debc3e5bf367c17f89f5e6136125?d=identicon)[mducharme](/maintainers/mducharme)

![](https://www.gravatar.com/avatar/0a4f39523b4b2837562ba0848a0327b8d340118d1ba87cb0f5d59b1d5cb6beba?d=identicon)[mcaskill](/maintainers/mcaskill)

---

Top Contributors

[![mducharme](https://avatars.githubusercontent.com/u/12157?v=4)](https://github.com/mducharme "mducharme (23 commits)")[![mcaskill](https://avatars.githubusercontent.com/u/29353?v=4)](https://github.com/mcaskill "mcaskill (8 commits)")[![BeneRoch](https://avatars.githubusercontent.com/u/3017380?v=4)](https://github.com/BeneRoch "BeneRoch (5 commits)")[![losted](https://avatars.githubusercontent.com/u/165665?v=4)](https://github.com/losted "losted (5 commits)")

---

Tags

searchcharcoal

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/locomotivemtl-charcoal-search/health.svg)

```
[![Health](https://phpackages.com/badges/locomotivemtl-charcoal-search/health.svg)](https://phpackages.com/packages/locomotivemtl-charcoal-search)
```

###  Alternatives

[elasticsearch/elasticsearch

PHP Client for Elasticsearch

5.3k178.3M943](/packages/elasticsearch-elasticsearch)[ruflin/elastica

Elasticsearch Client

2.3k50.4M203](/packages/ruflin-elastica)[opensearch-project/opensearch-php

PHP Client for OpenSearch

15024.3M65](/packages/opensearch-project-opensearch-php)[jeroen-g/explorer

Next-gen Elasticsearch driver for Laravel Scout.

397612.3k](/packages/jeroen-g-explorer)[manticoresoftware/manticoresearch-php

PHP Client for Manticore Search

206550.0k16](/packages/manticoresoftware-manticoresearch-php)[terminal42/escargot

A web crawler or spider library based on Symfony components

581.4M3](/packages/terminal42-escargot)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
