ZeroPing ZeroPing v2.0.1
Home Getting Started Installation Documentation Features API Roadmap Community
GitHub Star
Home Getting Started Installation Documentation Features API Roadmap Community GitHub GitHub
    Home Documentation Search
  • Introduction
  • Installation
  • Getting Started
  • CLI Reference
  • Validation
  • Caching
  • Database & ORM
  • Service Container
  • Queues & Jobs
  • Task Scheduler
  • Security
  • Extending ZeroPing
  • Starter Templates
  • Search
  • Performance
  • Roadmap

Documentation Search

ZeroPing includes a full-text search engine for your documentation, accessible via the search modal (Ctrl+K / Cmd+K) or the /search API endpoint.

Search Index

The search index is built from all markdown documents in docs/. Each document is parsed into words, stemmed, and stored with positional data for relevance scoring.

Building the Index

BASH
php zero search:index

This scans all .md files in the docs/ directory, builds a term-frequency map, and writes the index to storage/cache/search.index.

Automatic Rebuilding

The index is rebuilt automatically when:

  • You run php zero optimize
  • The search:index command is executed
  • A cache clear is performed with php zero optimize:clear

Search API

AJAX Endpoint

HTTP
GET /search?q=validation

Returns JSON:

JSON
{
    "query": "validation",
    "count": 3,
    "results": [
        {
            "title": "Validation",
            "url": "/docs/validation",
            "content": "…with <mark>validation</mark> rules…",
            "score": 0.95
        }
    ]
}

Frontend Integration

The search modal in views/layouts/site.php is wired to this endpoint with:

  • Debounced input — 250ms delay before searching
  • Recent searches — last 5 queries stored in localStorage
  • Highlighted results — matching terms are wrapped in <mark> tags
  • Empty state — friendly message when no results match
  • Error state — graceful fallback when the server is unreachable

Fuzzy Matching

Results that don't match exactly are ranked using Levenshtein distance. This means:

  • valdiation still finds "Validation"
  • instal finds "Installation"
  • gettin startd finds "Getting Started"

Scoring

Results are sorted by:

1. Title match (highest weight) 2. Content term frequency 3. Fuzzy distance (lower = better) 4. Document length (shorter = slightly preferred)

Only results above the relevance threshold (score > 0.2) are returned.

Starter Templates
Performance

On this page

  • Search Index
  • Building the Index
  • Automatic Rebuilding
  • Search API
  • AJAX Endpoint
  • Frontend Integration
  • Fuzzy Matching
  • Scoring
ESC

Type to search documentation...