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.
Installation
Section titled “Installation”Install a driver (which pulls in this contract automatically):
composer require marko/docs-ftsOr install the contract alone if you are building a custom driver:
composer require marko/docsType-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)); }}Customization
Section titled “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'; }}API Reference
Section titled “API Reference”DocsSearchInterface
Section titled “DocsSearchInterface”| Method | Returns | Description |
|---|---|---|
search(DocsQuery $query) | list<DocsResult> | Run a search; throws DocsException on failure |
getPage(string $id) | DocsPage | Fetch a single page by id |
listNav() | list<DocsNavEntry> | The documentation navigation tree |
driverName() | string | Identifier of the active driver (e.g. fts, vec) |
Value objects
Section titled “Value objects”DocsQuery—query: string,limit: int = 10DocsResult—pageId: string,title: string,excerpt: string,score: floatDocsPage—id: string,title: string,content: string,path: stringDocsNavEntry—id: string,title: string,path: string,depth: int = 0
Related Packages
Section titled “Related Packages”marko/docs-fts— lexical search drivermarko/docs-markdown— the canonical documentation content the driver indexes