Getting Started
Getting Started
Install PhrameCMS from phramecms/skeleton, run the idempotent site installer, and make your first JSON:API and MCP calls.
Getting Started
This guide walks you from a clean checkout of phramecms/skeleton to a live local PhrameCMS instance with an initialized database, Admin UI access, a scoped AI Agent Token, and working JSON:API and Model Context Protocol (MCP) calls.
Requirements
Choose either the optional Docker development workflow or a native PHP environment:
- Bare PHP path: PHP
^8.5(withpdo_sqlite,pdo_pgsql, orpdo_mysql) and Composer^2.8 - Optional Docker path: Docker Engine and Docker Compose v2
1. Create a PhrameCMS Project
Scaffold a new project from phramecms/skeleton:
composer create-project phramecms/skeleton my-phrame-site
cd my-phrame-siteThe starter project gives you thin, production-safe entrypoints backed by phramecms/cms (phramecms/core + all 10 official modules):
public/index.php— PSR-7/PSR-15 HTTP entrypoint (Admin UI at/admin, Headless JSON:API at/api/v1/*, Streamable HTTP MCP at/mcp)bin/phrame— Structured CLI binary supporting--jsonbin/phrame-mcp— Deny-by-default authenticated Stdio MCP serverbin/devanddocker-dev/— Optional local-development Docker Compose stack (nginx+php:8.5-fpm-alpine), safe to remove if unusedconfig/modules.php— Declarative project-local module registryconfig/sync/— Git-tracked canonical JSON configuration sync directory
2. Boot Your Local Runtime
PhrameCMS does not dictate your hosting stack. Use either bare PHP 8.5 or the optional docker-dev/ stack.
Option A: Bare PHP 8.5 (composer serve)
Copy the example environment file:
cp .env.example .envLeaving PHRAME_DSN= empty defaults to SQLite at <project-root>/var/phrame.sqlite.
Start PHP's built-in development server (serves public/index.php on http://127.0.0.1:8080):
composer serveOption B: Optional Local Docker Stack (docker-dev/)
Start the default 2-container stack (nginx + php, backed by SQLite at var/phrame.sqlite):
./bin/dev up -dTo test against PostgreSQL or MariaDB locally instead, pass a database overlay flag:
# PostgreSQL overlay (docker-dev/compose.postgres.yaml)
./bin/dev up --db-backend=postgres -d
# MariaDB overlay (docker-dev/compose.mariadb.yaml)
./bin/dev up --db-backend=mariadb -dIf vendor/ is not yet installed, run Composer inside the PHP container:
./bin/dev exec php composer installWhen using Docker, prefix CLI commands in the sections below with ./bin/dev exec php. Stop the stack when finished with ./bin/dev down.
3. Run the Idempotent Site Installer
Run ./bin/phrame site:install (App\Command\SiteInstallCommand) to install all registered module database schemas (SchemaInstallRunner), create the default admin role (role_admin with *) and administrator account, and optionally mint an initial AI Agent Token:
./bin/phrame site:install \
--issue-agent-token \
--agent-name=dev-agent \
--agent-scopes='schema.read,entity.content.article.read,entity.content.article.create'Verified site:install Flags
| Flag | Default | Description |
|---|---|---|
--admin-user=<name> |
admin |
Username for the initial administrator account |
--admin-email=<email> |
admin@example.com |
Email address for the initial administrator account |
--admin-password=<pass> |
(random strong password) | Explicit administrator password (when omitted, a random password is generated and displayed once) |
--issue-agent-token |
false |
Issue a scoped AI Agent Token attributed on_behalf_of the admin user |
--agent-name=<name> |
local-dev-agent |
Display name for the issued AI Agent Token |
--agent-scopes=<csv> |
* |
Comma-separated permission scopes for the issued AI Agent Token |
--json |
false |
Emit structured JSON output including schemas_installed, admin_user, generated_password, and agent_token |
site:install is idempotent: re-running it never overwrites an existing administrator password, while still installing any newly registered module schemas and issuing a fresh token when --issue-agent-token is passed. Record the generated admin password and plaintext_token shown once in the output.
Least privilege: Prefer explicit comma-separated scopes over
--agent-scopes='*'for real agents. See Users, RBAC, and AI Agent Tokens for permission syntax and scope design.
Open http://127.0.0.1:8080/admin and sign in with your administrator credentials.
4. Make Your First JSON:API Calls
Public OpenAPI 3.1 Specification
GET /api/v1/openapi.json is public by default (ApiRouteProvider marks it with meta: ['public' => true]) and dynamically reflects every registered entity type, bundle, and field:
curl -fsS http://127.0.0.1:8080/api/v1/openapi.json | head -c 400Authenticated Content Collection Request
All /api/v1/content/*, /api/v1/config/*, and /api/v1/schema/* routes require a Bearer AI Agent Token via BearerAuthMiddleware (deny-by-default).
Once you have defined an entity type and bundle (for example content / article via /admin/schema or the entity_type.create and bundle.create operations), query it over JSON:API (application/vnd.api+json):
curl -fsS http://127.0.0.1:8080/api/v1/content/content/article \
-H "Authorization: Bearer <AGENT_TOKEN>" \
-H "Accept: application/vnd.api+json"Create a content entity (optionally add ?dry_run=1 to preview without persisting, or send an Idempotency-Key header for safe retries):
curl -fsS -X POST "http://127.0.0.1:8080/api/v1/content/content/article" \
-H "Authorization: Bearer <AGENT_TOKEN>" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: create-hello-world-1" \
-d '{
"data": {
"type": "content--article",
"attributes": {
"title": "Hello PhrameCMS"
}
}
}'5. Make Your First MCP Calls
PhrameCMS exposes registered OperationBus operations as MCP tools (with dots sanitized to underscores, e.g. auth.whoami → auth_whoami, entity.schema → entity_schema) and read-only state as phrame:// MCP resources. Both transports enforce deny-by-default authentication via TokenAuthenticatorInterface and filter visible tools with RbacPolicyEnforcer::canDiscover().
Option A: Streamable HTTP MCP (POST /mcp)
Send JSON-RPC 2.0 requests to POST /mcp with your Bearer Agent Token:
# List tools permitted for this token's scopes
curl -fsS -X POST http://127.0.0.1:8080/mcp \
-H "Authorization: Bearer <AGENT_TOKEN>" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'
# Verify identity and granted scopes with auth_whoami
curl -fsS -X POST http://127.0.0.1:8080/mcp \
-H "Authorization: Bearer <AGENT_TOKEN>" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"auth_whoami","arguments":{}}}'Option B: Stdio MCP (./bin/phrame-mcp)
Configure your MCP client (IDE or desktop agent) to launch ./bin/phrame-mcp with PHRAME_MCP_TOKEN (or --token=<AGENT_TOKEN>):
{
"mcpServers": {
"phramecms": {
"command": "/path/to/my-phrame-site/bin/phrame-mcp",
"env": {
"PHRAME_MCP_TOKEN": "<AGENT_TOKEN>"
}
}
}
}If the token is missing, invalid, expired, or revoked, App\Mcp\StdioRunner writes a diagnostic message to stderr (keeping stdout clean for JSON-RPC framing) and exits with code 3 (ExitCode::AuthorizationDenied).
Next Steps
- Learn how the micro-kernel, 10 official modules, and
OperationBusfit together in Architecture Overview. - Track site configuration and schemas in Git with Configuration Sync.
- Configure roles, scoped tokens, and auditing in Users, RBAC, and AI Agent Tokens.
- Stage AI-authored changes for human review in AI Change Proposals & Human Approval Queue.