Skip to content

docs(readme): rewrite the "library" example to match the real surface#62

Merged
bigin merged 1 commit into
masterfrom
docs/readme-library-example
May 16, 2026
Merged

docs(readme): rewrite the "library" example to match the real surface#62
bigin merged 1 commit into
masterfrom
docs/readme-library-example

Conversation

@bigin
Copy link
Copy Markdown
Owner

@bigin bigin commented May 16, 2026

The old snippet handed the reader an opaque $item via iManager's low-level ItemRepository->find(1). Three things wrong with that:

  1. $item is the abstract polytype — page/user/file/whatever. The reader doesn't know what they got.
  2. ID 1 is magic; a fresh install may not even have it.
  3. "Use Scriptor as a library" framing was undermined by reaching straight into iManager instead of using Scriptor's own surface.

Switch to require boot.php (single line — autoloader, container, $config all set up). Then show the two natural library use-cases end-to-end: page data access via $site->pages()->findHome(), and theme rendering via $site->execute() + $site->render(). Both smoke-tested against the live DB.

The old snippet handed the reader an opaque \$item via iManager's
low-level ItemRepository->find(1). Three things wrong with that:
1. \$item is the abstract polytype — page/user/file/whatever. The
   reader doesn't know what they got.
2. ID 1 is magic; a fresh install may not even have it.
3. "Use Scriptor as a library" framing was undermined by reaching
   straight into iManager instead of using Scriptor's own surface.

Switch to require boot.php (single line — autoloader, container,
\$config all set up). Then show the two natural library use-cases
end-to-end: page data access via \$site->pages()->findHome(), and
theme rendering via \$site->execute() + \$site->render(). Both
smoke-tested against the live DB.
@bigin bigin merged commit 5682deb into master May 16, 2026
@bigin bigin deleted the docs/readme-library-example branch May 16, 2026 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant