|
| 1 | +# API Reference |
| 2 | + |
| 3 | +Reference documentation for the iManager 2.0 library — every public class |
| 4 | +you can wire, extend, or call from a host application. |
| 5 | + |
| 6 | +> **Where to start:** the [README quickstart](../../README.md#quickstart) |
| 7 | +> shows the shortest path from `composer require` to a saved item using |
| 8 | +> `Imanager\DefaultBootstrap::boot()`. This reference picks up from |
| 9 | +> there. It documents the *contracts* you can program against, not the |
| 10 | +> SQLite internals. |
| 11 | +
|
| 12 | +--- |
| 13 | + |
| 14 | +## Core (covered in detail here) |
| 15 | + |
| 16 | +The four pages below cover ~90 % of what host code touches. Read them |
| 17 | +in order if you're new — each one builds on the previous. |
| 18 | + |
| 19 | +- **[Domain](domain.md)** — `Category`, `Field`, `Item`, `File`, |
| 20 | + `FieldValueBag`, and the nine domain events (`*Created`, `*Updated`, |
| 21 | + `*Deleted`). All domain objects are `final readonly`; you mutate by |
| 22 | + saving a new value. |
| 23 | +- **[Storage](storage.md)** — the `Storage` interface and its four |
| 24 | + repositories (`CategoryRepository`, `FieldRepository`, |
| 25 | + `ItemRepository`, `FileRepository`), `SqliteStorage` (the only |
| 26 | + bundled implementation), and the `transactional()` boundary. Also |
| 27 | + covers `SchemaManager` and `Migration`. |
| 28 | +- **[Query](query.md)** — the immutable `Query` builder, the |
| 29 | + `Clause` / `Operator` / `OrderBy` / `Direction` value objects, |
| 30 | + `Pagination`, and the `SelectorParser` shorthand |
| 31 | + (`name=Hello*, position>=5`). |
| 32 | +- **[Field types](field-types.md)** — the `FieldTypePlugin` |
| 33 | + interface, `FieldTypeRegistry`, the 16 built-in plugins, and the |
| 34 | + `ValidationResult` / `RenderContext` value objects you return / |
| 35 | + receive when writing your own type. |
| 36 | + |
| 37 | +--- |
| 38 | + |
| 39 | +## Subsystem index |
| 40 | + |
| 41 | +Every namespace under `Imanager\` at a glance. The "Reference" column |
| 42 | +either points to the detail page or — for the smaller subsystems — |
| 43 | +tells you which source file to read next. |
| 44 | + |
| 45 | +| Namespace | What it does | Reference | |
| 46 | +|---|---|---| |
| 47 | +| `Imanager\Domain` | Typed primitives (`Category`, `Field`, `Item`, `File`) and domain events. The whole model is `final readonly`. | [Domain](domain.md) | |
| 48 | +| `Imanager\Storage` | Repository contracts and the SQLite implementation. Items are persisted as a `JSON` column with hot fields promoted to generated columns. | [Storage](storage.md) | |
| 49 | +| `Imanager\Query` | Immutable query builder + `SelectorParser` string DSL. `ItemRepository::query()` is the single execution entrypoint. | [Query](query.md) | |
| 50 | +| `Imanager\Field` | Field-type plugin system: 16 built-in types and the registry that resolves them by name. | [Field types](field-types.md) | |
| 51 | +| `Imanager\Enum` | `FieldType` (the 16 built-in enum cases), `SqliteAffinity` (storage class hint), `InputErrorCode` (validation error codes). | `src/Enum/` | |
| 52 | +| `Imanager\Files` | File-storage abstraction (`FileStorage` interface, `LocalFileStorage`), upload validation, and `ImageProcessor` for on-demand thumbnails. `FileRepository` (under `Storage`) tracks file *metadata*; this subsystem moves the bytes. | `src/Files/` | |
| 53 | +| `Imanager\Http` | Small request-layer toolkit: `SessionStore` (with `NativeSessionStore` default), `Csrf` (per-form tokens, capped LRU), and request/URL helpers. iManager does *not* ship a router. | `src/Http/` | |
| 54 | +| `Imanager\Cache` | PSR-16 cache contract and `FilesystemCache` (hash-keyed, two-level directory fanout, TTL metadata in-file). Used by Scriptor for section-cache; library itself stays uncached for predictability. | `src/Cache/` | |
| 55 | +| `Imanager\Search` | `FullTextSearch` over a SQLite FTS5 mirror of `items`. CLI command `fts:rebuild` rebuilds the index from scratch. | `src/Search/` | |
| 56 | +| `Imanager\Templating` | Single-purpose `{{var}}` substitution for short strings (pagination links, alerts). Caller is responsible for escaping. **Not** a view layer. | `src/Templating/` | |
| 57 | +| `Imanager\Validation` | `Sanitizer` facade over HTMLPurifier (sanitize) and Parsedown (markdown). Pure functions; safe to call repeatedly. | `src/Validation/` | |
| 58 | +| `Imanager\Events` | PSR-14 dispatcher (`SyncEventDispatcher`) and provider (`SubscriberListenerProvider`). Domain events flow through this; subscribe in your bootstrap. | `src/Events/` | |
| 59 | +| `Imanager\Exception` | Hierarchy rooted at the `ImanagerException` marker interface: `StorageException`, `ValidationException`, `NotFoundException`, `SchemaException`, `FieldTypeNotRegisteredException`. Catch the marker if you want a single net. | `src/Exception/` | |
| 60 | +| `Imanager\Cli` | Symfony Console application (`vendor/bin/imanager`). Commands: `schema:status`, `schema:migrate`, `migrate:from-v1`, `fts:rebuild`, `optimize`, `repair`, `dump`. | `src/Cli/` and the [README CLI table](../../README.md#cli) | |
| 61 | + |
| 62 | +--- |
| 63 | + |
| 64 | +## Conventions used in this reference |
| 65 | + |
| 66 | +- **`final readonly`** — every domain primitive and most value objects |
| 67 | + are immutable. Operations like `withId()`, `withTitle()`, or the |
| 68 | + builder methods on `Query` return a new instance. |
| 69 | +- **Method signatures** are quoted **verbatim** from the source — same |
| 70 | + parameter names, defaults, and return types. If something looks |
| 71 | + surprising, check the file path at the top of each page; the source |
| 72 | + wins, this doc follows. |
| 73 | +- **Examples** are lifted from the contract tests under |
| 74 | + `tests/Unit/Storage/*Contract.php`. Those tests run against both |
| 75 | + `SqliteStorage` and the `InMemory` storage shipped for testing — so |
| 76 | + every example you see compiles and is exercised on every CI run. |
| 77 | +- **Exceptions thrown** are listed under each method that can throw. |
| 78 | + Methods without a "Throws" line never throw in normal operation |
| 79 | + (errors surface as `null` returns or empty lists where appropriate). |
| 80 | + |
| 81 | +--- |
| 82 | + |
| 83 | +## Roadmap |
| 84 | + |
| 85 | +The four core pages cover the public API any application boots |
| 86 | +against. Still to come in Phase 16: |
| 87 | + |
| 88 | +- `docs/field-types.md` — **cookbook** (distinct from |
| 89 | + `docs/api/field-types.md` reference): how to write a custom field |
| 90 | + type end-to-end, including form rendering and validation patterns. |
| 91 | +- `docs/query-cookbook.md` — recipes for the `Query` builder and |
| 92 | + selector strings (faceted lookups, pagination flows, FTS hand-off). |
| 93 | +- `docs/deployment.md` — production deployment (Caddy / nginx, file |
| 94 | + permissions, backup, scheduled `optimize`). |
| 95 | + |
| 96 | +The smaller subsystems (Cache, Templating, Http, Events, Validation) |
| 97 | +will get their own reference pages **only if** non-trivial host |
| 98 | +extension is expected — for now their source files are short and |
| 99 | +documented inline. |
0 commit comments