{"id":16710825,"url":"https://github.com/chris48s/cakephp-searchable","last_synced_at":"2025-04-10T05:35:51.211Z","repository":{"id":4758998,"uuid":"52722880","full_name":"chris48s/cakephp-searchable","owner":"chris48s","description":":cake: A CakePHP 3 behavior for creating MySQL MATCH() AGAINST() queries :mag:","archived":false,"fork":false,"pushed_at":"2022-04-20T07:02:12.000Z","size":25,"stargazers_count":4,"open_issues_count":2,"forks_count":4,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-24T06:51:53.233Z","etag":null,"topics":["cakephp","fulltext-indexes","mysql"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/chris48s/cakephp-searchable","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chris48s.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-28T13:37:21.000Z","updated_at":"2023-10-29T17:19:38.000Z","dependencies_parsed_at":"2022-08-06T17:31:07.229Z","dependency_job_id":null,"html_url":"https://github.com/chris48s/cakephp-searchable","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chris48s%2Fcakephp-searchable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chris48s%2Fcakephp-searchable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chris48s%2Fcakephp-searchable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chris48s%2Fcakephp-searchable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chris48s","download_url":"https://codeload.github.com/chris48s/cakephp-searchable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247967044,"owners_count":21025700,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cakephp","fulltext-indexes","mysql"],"created_at":"2024-10-12T20:09:42.174Z","updated_at":"2025-04-10T05:35:51.191Z","avatar_url":"https://github.com/chris48s.png","language":"PHP","readme":"[![Build Status](https://travis-ci.org/chris48s/cakephp-searchable.svg?branch=master)](https://travis-ci.org/chris48s/cakephp-searchable)\n[![Coverage Status](https://coveralls.io/repos/github/chris48s/cakephp-searchable/badge.svg?branch=master)](https://coveralls.io/github/chris48s/cakephp-searchable?branch=master)\n\n# CakePHP Searchable Behavior Plugin\n\nA CakePHP 3 Behavior for creating MySQL [MATCH() AGAINST() queries](https://dev.mysql.com/doc/refman/5.6/en/fulltext-search.html).\n\nCakePHP-Searchable adds a custom `find('matches')` method to your CakePHP models, alleviating the need to pass raw SQL into your queries. It is safe against SQL injection and uses a query syntax which is consistent with the conventions of CakePHP's ORM.\n\n## Installation\n\nInstall from [packagist](https://packagist.org/packages/chris48s/cakephp-searchable) using [composer](https://getcomposer.org/).\nAdd the following to your `composer.json`:\n\n```\n\"require\": {\n    \"chris48s/cakephp-searchable\": \"^2.0.0\"\n}\n```\n\nand run `composer install` or `composer update`, as applicable.\n\n## Database Support\n\nIn order to use FULLTEXT indexes on InnoDB tables, you must be using MySQL \u003e=5.6.4. Earlier versions only allow use of FULLTEXT indexes on MyISAM tables.\n\n## Usage\n\n### Loading the plugin\n\nAdd the code `Plugin::load('Chris48s/Searchable');` to your `bootstrap.php`.\n\n### Using the Behavior\n\nAdd the behavior in your table class.\n\n```php\n\u003c?php\nnamespace App\\Model\\Table;\n\nuse Cake\\ORM\\Table;\n\nclass MyTable extends Table\n{\n\n    public function initialize(array $config)\n    {\n        parent::initialize($config);\n        $this-\u003eaddBehavior('Chris48s/Searchable.Searchable');\n    }\n}\n```\n### Querying data\n\nHaving added the behavior to a table class, you now have access to the query method `find('matches')`, which you can use to construct MATCH() AGAINST() queries. For example:\n\n```php\n\u003c?php\n\nuse Cake\\ORM\\TableRegistry;\n\n$myTable = TableRegistry::get('MyTable');\n\n$query = $myTable\n    -\u003efind('matches', [\n        [\n            'match' =\u003e 'textcol1',\n            'against' =\u003e 'foo'\n        ],\n        [\n            'match' =\u003e 'textcol2, textcol3',\n            'against' =\u003e '+foo bar*',\n            'mode' =\u003e 'IN BOOLEAN MODE'\n        ]\n    ]);\n```\n\nAvailable modes are:\n* `'IN NATURAL LANGUAGE MODE'`\n* `'IN BOOLEAN MODE'`\n* `'WITH QUERY EXPANSION'`\n* `'IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION'`\n\nWhen using boolean mode, some [additional operators](https://dev.mysql.com/doc/refman/5.6/en/fulltext-boolean.html) are available.\n\nThe method `find('matches')` returns a CakePHP query object, so you can chain\nadditional methods on to this (e.g: `-\u003ewhere()`, `-\u003eorder()`, `-\u003elimit()`, etc).\n\n## Error Handling\nIf the keys `'match'` or `'against'` are not set, or if any of the columns contained in the column list are not of type `string` or `text`, an exception of class `SearchableException` will be thrown.\n\n## Reporting Issues\nIf you have any issues with this plugin then please feel free to create a new [Issue](https://github.com/chris48s/cakephp-searchable/issues) on the [GitHub repository](https://github.com/chris48s/cakephp-searchable). This plugin is licensed under the MIT Licence.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchris48s%2Fcakephp-searchable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchris48s%2Fcakephp-searchable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchris48s%2Fcakephp-searchable/lists"}