keiro/php-js-search

A client or server side search engine for use on static pages.

1.1.1 2019-12-22 23:00 UTC

This package is auto-updated.

Last update: 2024-09-23 09:32:49 UTC


README

This is a client side search engine for use on static pages.

It uses a pre-compiled search index to add a fulltext search to static HTML pages such as github pages or offline API documentation. The index is built by a PHP script using a similar yet much more simplified and dump approach than the popular search engine Lucene.

To see how it looks like, check out the demo.

Installation

PHP 5.6 or higher is required to run the index generator.

Installation is recommended to be done via composer by adding the following to the require section in your composer.json:

{ "require" : 
  {
  "keiro/php-js-search": "~1.0"
  }
}

Alternatively run composer require "keiro/php-js-search".

Generate the index

Using the command line tool:

vendor/bin/generateindex <path-to-your-html-files>

js

This will generate a jssearch.index.js file that you have to include in the HTML header.

php

This will generate a search-engine-index.php in data folder. Example to generate php sqlite index :

vendor/bin/generateindex tests/ -l php -db

Usage

See example.html for a js implementation.
See example-php.html for a php implementation. Notice that the phpsearch.php file act as an endpoint. Feel free to integrate its logic in your own framework.