Skip to content

marko/docs

Documentation search contract for Marko — defines the interface for querying Marko documentation, with interchangeable driver implementations. marko/docs ships no search implementation; it defines DocsSearchInterface and the value objects that drivers return. Install a driver to get a working search backend.

This package defines a contract only. Install a driver for implementation:

  • marko/docs-fts — lightweight lexical search (SQLite FTS5)

A driver implements DocsSearchInterface, so an app depends on the contract and stays decoupled from the backend.

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

Terminal window
composer require marko/docs-fts

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

Terminal window
composer require marko/docs

Type-hint DocsSearchInterface and let the installed driver handle the backend:

use Marko\Docs\Contract\DocsSearchInterface;
use Marko\Docs\ValueObject\DocsQuery;
class DocsController
{
public function __construct(
private DocsSearchInterface $docs,
) {}
public function search(string $term): array
{
// Returns list<DocsResult>
return $this->docs->search(new DocsQuery($term, limit: 10));
}
}

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'; }
}
MethodReturnsDescription
search(DocsQuery $query)list<DocsResult>Run a search; throws DocsException on failure
getPage(string $id)DocsPageFetch a single page by id
listNav()list<DocsNavEntry>The documentation navigation tree
driverName()stringIdentifier of the active driver (e.g. fts, vec)
  • DocsQuery — query: string, limit: int = 10
  • DocsResult — pageId: string, title: string, excerpt: string, score: float
  • DocsPage — id: string, title: string, content: string, path: string
  • DocsNavEntry — id: string, title: string, path: string, depth: int = 0
  • marko/docs-fts — lexical search driver
  • marko/docs-markdown — the canonical documentation content the driver indexes