Skip to content

marko-php/marko-docs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

marko/docs

Documentation search contract for Marko — defines the interface for querying Marko documentation, with interchangeable driver implementations.

Overview

marko/docs is the contract package that defines how Marko documentation is searched. It ships no search implementation — install a driver instead: marko/docs-fts for lightweight lexical search (SQLite FTS5) or marko/docs-vec for hybrid semantic + lexical search (FTS5 + sqlite-vec). Both drivers implement the same DocsSearchInterface, so switching is a one-line dependency change.

Installation

Install a driver (which pulls in this package automatically):

# Lightweight lexical search
composer require marko/docs-fts

# Hybrid semantic + lexical search
composer require marko/docs-vec

Or install the contract alone if you are building a custom driver:

composer require marko/docs

Usage

use Marko\Docs\Contract\DocsSearchInterface;
use Marko\Docs\ValueObject\DocsQuery;

class DocsController
{
    public function __construct(
        private DocsSearchInterface $docs,
    ) {}

    public function search(string $term): array
    {
        return $this->docs->search(new DocsQuery($term, limit: 10));
    }
}

Customization

Implement DocsSearchInterface and register your implementation as a Preference:

#[Preference(DocsSearchInterface::class)]
class MyDocsSearch implements DocsSearchInterface
{
    public function search(DocsQuery $query): array { /* ... */ }
    public function getPage(string $id): DocsPage { /* ... */ }
    public function listNav(): array { /* ... */ }
    public function driverName(): string { return 'custom'; }
}

Documentation

Full driver comparison and API reference: marko/docs

About

[READ-ONLY] Documentation search contract for Marko Framework. Issues and PRs at https://github.com/marko-php/marko

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages