Search by

phramecms / skeleton

TLyngeJ

Runnable PHP 8.5 starter project template for PhrameCMS.

Package info

github.com/PhrameCMS/skeleton

Type:project

pkg:composer/phramecms/skeleton

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-12-04 21:21 UTC

This package is auto-updated.

Last update: 2026-12-04 21:35:32 UTC


README

Runnable PHP 8.5 starter project template for PhrameCMS (composer create-project phramecms/skeleton).

Requires the phramecms/cms metapackage (bundling core and all 10 official modules) and provides thin, production-safe entrypoints to run a live PhrameCMS instance:

  • public/index.php — PSR-7/PSR-15 HTTP SAPI entrypoint (Admin UI at /admin, Headless REST API, OpenAPI 3.1, Streamable HTTP MCP)
  • bin/phrame — Structured CLI binary (site:install, schema:install, user:login, user:password, modules:list, op:list, op:describe, op:run, --json)
  • bin/phrame-mcp — Deny-by-default authenticated Stdio MCP server for local AI agents
  • bin/dev & docker-dev/ — Optional local-development-only Docker Compose setup (nginx + php:8.5-fpm-alpine) with selectable database backend overlays (safe to delete if unused)
  • modules/ — Dedicated root directory for site-specific custom PHP modules (PSR-4 namespace Modules\; official phramecms/* and community contrib modules stay in vendor/)
  • config/modules.php.example — Update-safe module registry template copied to config/modules.php by ./bin/phrame site:install when missing (never overwritten; auto-loaded across HTTP, CLI, and MCP)
  • config/sync/ — Git-tracked canonical JSON configuration sync directory

Requirements

  • Docker path: Docker Engine + Docker Compose v2
  • Bare PHP path: PHP ^8.5 (with pdo_sqlite, pdo_pgsql, or pdo_mysql) and Composer ^2.8

Quickstart — Local Dev Docker (docker-dev/, Optional)

Everything Docker-related lives inside docker-dev/ and is strictly for local development — PhrameCMS does not dictate your hosting stack, and you can delete docker-dev/ (rm -rf docker-dev) if you prefer native PHP or another runtime.

1. Start the local stack

By default, PhrameCMS runs only 2 containers (nginx + php) backed by SQLite at var/phrame.sqlite (no database container required):

./bin/dev up -d
# Equivalent raw command:
docker compose -f docker-dev/compose.yaml up -d

To develop against PostgreSQL or MariaDB instead, pass --db-backend=postgres or --db-backend=mariadb (which composes the matching overlay file from docker-dev/):

# PostgreSQL 17
./bin/dev up --db-backend=postgres -d
# Equivalent raw command:
docker compose -f docker-dev/compose.yaml -f docker-dev/compose.postgres.yaml up -d

# MariaDB 11.8
./bin/dev up --db-backend=mariadb -d
# Equivalent raw command:
docker compose -f docker-dev/compose.yaml -f docker-dev/compose.mariadb.yaml up -d

Root .env with raw docker compose: Docker Compose resolves its default .env relative to docker-dev/, so the bare docker compose -f docker-dev/compose.yaml ... commands work out of the box when no root .env exists, but ignore a project-root .env (PHRAME_HTTP_PORT, PHRAME_DB_*, etc.). If you customize .env in the project root, use ./bin/dev (which passes --env-file .env automatically when .env exists) or pass --env-file .env explicitly (e.g. docker compose --env-file .env -f docker-dev/compose.yaml up -d).

Install Composer dependencies inside the PHP container if vendor/ is not yet present:

./bin/dev exec php composer install

./bin/dev automatically maps the php container user to your host UID:GID (PHRAME_UID/PHRAME_GID), keeping var/ and config/sync/ cleanly writable by both CLI commands and HTTP requests without root-owned files.

2. Run the idempotent installer

Initialize all database schemas, scaffold config/modules.php from config/modules.php.example if missing, create the default admin role & administrator account, and mint a scoped AI Agent Token:

./bin/dev exec php ./bin/phrame site:install \
  --issue-agent-token \
  --agent-name=dev-agent \
  --agent-scopes='*'

Save the generated admin password and plaintext_token shown once in the output. Re-running site:install without --issue-agent-token is an idempotent no-op and never overwrites an existing admin password or config/modules.php, whereas passing --issue-agent-token intentionally mints a new agent token on each invocation. Pass --json for machine-readable output.

3. Open the Admin UI & verify the live HTTP API

Open http://127.0.0.1:8080/admin in your browser and sign in with the administrator username (admin) and generated password printed by ./bin/phrame site:install.

Verify the OpenAPI document over HTTP:

curl -fsS http://127.0.0.1:8080/api/v1/openapi.json | head -c 300

Stop containers when finished:

./bin/dev down
# Or with an overlay:
./bin/dev down --db-backend=postgres

Quickstart — Bare PHP (No Docker)

1. Create the project and install dependencies

composer create-project phramecms/skeleton my-phrame-site
cd my-phrame-site

Or if you cloned this repository directly:

composer install

2. Configure environment

cp .env.example .env

By default, leaving PHRAME_DSN= empty uses SQLite at <project-root>/var/phrame.sqlite.

3. Run the installer

./bin/phrame site:install \
  --issue-agent-token \
  --agent-name=dev-agent \
  --agent-scopes='*'

4. Start the local HTTP server

composer serve

This starts PHP's built-in server at http://127.0.0.1:8080 serving public/index.php.

5. Open the Admin UI & verify HTTP API / CLI

Open http://127.0.0.1:8080/admin in your browser and sign in with the administrator username (admin) and generated password printed by ./bin/phrame site:install.

curl -fsS http://127.0.0.1:8080/api/v1/openapi.json | head -c 300
./bin/phrame op:list --json

Connecting AI Agents via MCP

All MCP transports enforce deny-by-default authentication via TokenAuthenticatorInterface and execute every mutation through OperationBus with full RBAC scope enforcement and audit logging.

First, mint a least-privilege scoped token tailored to the agent's task (rather than *):

./bin/phrame site:install \
  --issue-agent-token \
  --agent-name=content-assistant \
  --agent-scopes='schema.read,entity.content.article.read,entity.content.article.create' \
  --json

Option A: Stdio MCP (./bin/phrame-mcp)

Add the following entry to your MCP client configuration (e.g., Claude Desktop, Cursor, Antigravity, or any MCP-compatible IDE):

{
  "mcpServers": {
    "phramecms": {
      "command": "/path/to/your-project/bin/phrame-mcp",
      "env": {
        "PHRAME_MCP_TOKEN": "<YOUR_SCOPED_AGENT_TOKEN>"
      }
    }
  }
}

You can also pass the token via --token=<YOUR_SCOPED_AGENT_TOKEN>. If the token is missing, invalid, expired, or revoked, bin/phrame-mcp writes a diagnostic to stderr (leaving stdout empty) and exits with code 3.

Option B: Streamable HTTP MCP (POST /mcp)

Send JSON-RPC 2.0 requests to POST http://127.0.0.1:8080/mcp with a Bearer Agent Token:

curl -fsS -X POST http://127.0.0.1:8080/mcp \
  -H "Authorization: Bearer <YOUR_SCOPED_AGENT_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'

AI Change Proposals & Human Approval Queue

PhrameCMS ships with ProposalModule wired out of the box so AI agents can stage sensitive configuration or schema changes without holding live write permissions, while human administrators review and approve them in /admin/proposals.

1. Mint a propose-only AI Agent Token

Grant proposal.create, proposal.read, and only the specific propose.* scopes the agent is allowed to stage (omit live write scopes and proposal.review — required by proposal.approve / proposal.reject — so the agent cannot mutate state directly or self-approve):

./bin/phrame site:install \
  --issue-agent-token \
  --agent-name=proposal-assistant \
  --agent-scopes='schema.read,config.admin.settings.read,proposal.create,proposal.read,propose.config.admin.settings.write,propose.schema.modify' \
  --json

2. Stage & track proposals over MCP

Connect the token over Stdio (./bin/phrame-mcp) or Streamable HTTP (POST /mcp):

  • Call the proposal.create tool with the target operation, input payload, and a human-readable reason (PhrameCMS validates and dry-runs the change to generate a canonical diff and optimistic-concurrency beforeHash).
  • Read phrame://proposals/pending to inspect queued changes awaiting review, or phrame://proposals/recent to see approval outcomes and any human review_note feedback on rejected proposals.

3. Review, approve, or reject in /admin/proposals

Sign in to /admin/proposals as a human administrator to inspect each queued proposal's canonical diff, proposing agent display label, and human attribution:

  • Approve: Applies the staged operation live through OperationBus, records an immutable audit trail linking the proposal and approval, and rejects stale proposals with 409 Conflict if the underlying state changed since staging.
  • Reject: Marks the proposal rejected with a review_note that the agent can immediately read back via phrame://proposals/recent.

Customizing the Admin Theme

You can customize the Admin UI at /admin without modifying vendor/ using three progressive tiers. Resolution precedence runs from project overrides (templates/admin/, assets/admin/) → active Composer theme (AdminThemeInterface) → built-in phramecms/admin defaults (@admin_base).

Tier 1: Tweaking Styles & Static Assets (assets/admin/)

Create an assets/admin/ directory in your project root (auto-detected on boot, or point PHRAME_ADMIN_ASSETS_DIR elsewhere):

  • Override the default stylesheet: drop assets/admin/admin.css to completely replace /admin/assets/admin.css (full stylesheet replacement; for additive :root token tweaks like --admin-primary, --admin-sidebar-bg, or --admin-bg without duplicating the built-in CSS, add assets/admin/custom.css and load it via Tier 2's head_extra block below).
  • Add extra static assets: drop additional allowlisted static files (css, js, svg, png, jpg, jpeg, webp, ico, woff2, woff) into assets/admin/ to serve them at /admin/assets/<filename> (for example, assets/admin/custom.css or assets/admin/logo.svg) while keeping admin.css and admin.js falling back to the active theme or built-in defaults.

Tier 2: Overriding a Twig Template or Block (templates/admin/)

Create a templates/admin/ directory in your project root (auto-detected on boot, or set PHRAME_ADMIN_TEMPLATES_DIR) and drop only the templates you want to override. All other templates fall back cleanly to the active theme and built-in phramecms/admin templates.

To customize individual blocks (title, head_extra, brand, topbar_actions, content, scripts_extra) without duplicating the entire layout, extend the built-in template via the @admin_base namespace — for example, templates/admin/layout.html.twig:

{% extends '@admin_base/layout.html.twig' %}

{% block head_extra %}
    <link rel="stylesheet" href="/admin/assets/custom.css">
{% endblock %}

Tier 3: Installing a Pluggable Composer Theme Package (AdminThemeInterface)

Install a Composer theme package whose module registers a service implementing PhrameCms\Admin\Contract\AdminThemeInterface tagged with AdminThemeInterface::SERVICE_TAG (phrame.admin_theme). If the package declares extra.phramecms.modules in its composer.json, it is discovered automatically; otherwise register it in config/modules.php (or pass it to AppBootstrap::boot($config, [new YourThemeModule()])).

Once registered, switch the active theme and brand name either:

  • In the Admin UI: open /admin/appearance to select an installed theme, set brand_name, preview the diff (dry_run), and save through OperationBus.
  • In Git-tracked configuration: set config/sync/admin.settings.json:
{
  "brand_name": "Acme CMS",
  "theme": "acme_dark"
}

Then apply it cleanly via ./bin/phrame op:run config.import --scopes=config.import.

Adding Custom Modules & Installing Schemas

You can add custom project modules or third-party Composer modules without editing AppBootstrap.php, public/index.php, bin/phrame, or bin/phrame-mcp:

1. Site-specific custom modules (modules/ & config/modules.php)

Place site-specific custom modules under the root modules/<Feature>/ directory using the PSR-4 namespace Modules\<Feature>\ (keeping src/ focused on skeleton bootstrap plumbing and keeping official phramecms/* and community contrib modules in vendor/ via Composer, with phramecms/cms as a pure metapackage).

phramecms/skeleton tracks config/modules.php.example rather than config/modules.php so upstream skeleton updates never overwrite or conflict with your site's module registrations. Running ./bin/phrame site:install automatically copies config/modules.php.example to config/modules.php if missing (and never overwrites an existing config/modules.php); commit your site's config/modules.php to your own project repository.

Register PhrameCms\Core\Contract\ModuleInterface class-strings (zero-argument constructors) or configured instances in config/modules.php:

<?php

declare(strict_types=1);

return [
    Modules\Blog\BlogModule::class,
    new Modules\Custom\CustomModule(featureFlag: true),
];

2. Composer package auto-discovery (extra.phramecms.modules)

Installed Composer packages that declare extra.phramecms.modules in their composer.json are discovered automatically from vendor/composer/installed.json:

{
  "extra": {
    "phramecms": {
      "modules": [
        "Vendor\\Pkg\\MyModule"
      ]
    }
  }
}

Set PHRAME_DISCOVER_COMPOSER_MODULES=0 in .env (or the process environment) to disable automatic Composer module discovery. To override a Composer-discovered module with custom constructor arguments, instantiate it directly in config/modules.php.

3. Installing custom module database schemas

Modules that register a PhrameCms\Database\Contract\SchemaInstallerInterface service tagged with SchemaInstallerInterface::SERVICE_TAG (phrame.schema_installer) are installed automatically by both ./bin/phrame site:install and ./bin/phrame schema:install.

To idempotently install tables for newly added modules on an existing site without touching admin users or agent tokens:

./bin/phrame schema:install
# Or machine-readable output:
./bin/phrame schema:install --json

User Administration CLI Commands

Resetting a user password (user:password)

Use ./bin/phrame user:password <username-or-id> to set or reset a user's password via OperationBus (user.set_password, revoking existing sessions by default):

# Generate a random strong password (displayed once)
./bin/phrame user:password admin --generate

# Read a new password from stdin without shell history exposure
printf 'MyNewStrongPassword123!\n' | ./bin/phrame user:password admin --password-stdin

# Set an explicit password while keeping existing sessions active
./bin/phrame user:password admin --password='MyNewStrongPassword123!' --keep-sessions

Generating a one-time Admin login link (user:login)

Use ./bin/phrame user:login [username|email|id] (defaults to admin) to mint a short-lived, single-use Admin UI login URL:

# Default admin account (uses PHRAME_BASE_URL or http://127.0.0.1:<PHRAME_HTTP_PORT>)
./bin/phrame user:login

# Target a specific user with custom base URL, TTL, and destination
./bin/phrame user:login editor --uri=https://cms.example.com --ttl=300 --redirect=/admin/content

# Machine-readable JSON output
./bin/phrame user:login --json

Configuration Sync Workflow

PhrameCMS stores active configuration in the database (DatabaseConfigStorage) and syncs canonical, deterministically sorted JSON files with config/sync/ (FileConfigStorage) so schema and site configuration can be reviewed in Git and deployed safely across environments.

# Export active database configuration into config/sync/
./bin/phrame op:run config.export --scopes=config.export

# Inspect differences between active configuration and config/sync/
./bin/phrame op:run config.diff --scopes=config.read

# Preview an import from config/sync/ without mutating state
./bin/phrame op:run config.import --dry-run --scopes=config.import

# Atomically apply configuration from config/sync/ (auto-creates a rollback snapshot)
./bin/phrame op:run config.import --scopes=config.import

Add --json to any command for structured JSON output, or --actor-id=<admin-user-id> to run as a specific database user with their assigned RBAC roles.

Environment Variables

Variable Default Description
PHRAME_DSN sqlite:<project-root>/var/phrame.sqlite Database DSN (sqlite:..., pgsql://..., mysql://..., memory://)
PHRAME_CONFIG_SYNC_DIR <project-root>/config/sync Canonical JSON configuration sync directory
PHRAME_DEBUG 0 (1 in docker-dev/compose.yaml) Enable detailed error diagnostics (1/true in local dev only; keep 0 in production)
PHRAME_DISCOVER_COMPOSER_MODULES 1 Automatically discover installed Composer packages declaring extra.phramecms.modules (0/false to disable)
PHRAME_ADMIN_SECURE_COOKIE 0 Enforce the Secure attribute on /admin session cookies (0 for local HTTP dev; set to 1 in HTTPS production)
PHRAME_ADMIN_TEMPLATES_DIR <project-root>/templates/admin (when present) Optional project-level Admin Twig template override directory
PHRAME_ADMIN_ASSETS_DIR <project-root>/assets/admin (when present) Optional project-level Admin static asset override directory
PHRAME_MCP_TOKEN (unset) Scoped AI Agent Token used by bin/phrame-mcp when --token is not passed
PHRAME_MCP_AUDIT_DEFAULT_LIMIT 100 Default entry limit returned by MCP audit resources
PHRAME_HTTP_PORT 8080 Host port bound by nginx in docker-dev/compose.yaml
PHRAME_BASE_URL http://127.0.0.1:<PHRAME_HTTP_PORT> Optional public base URL used by CLI commands such as user:login
PHRAME_UID 1000 (host id -u via bin/dev) Non-root UID used by the php container in docker-dev/compose.yaml
PHRAME_GID 1000 (host id -g via bin/dev) Non-root GID used by the php container in docker-dev/compose.yaml
PHRAME_DB_NAME phrame Local Docker dev database name for Postgres/MariaDB overlays
PHRAME_DB_USER phrame Local Docker dev database user for Postgres/MariaDB overlays
PHRAME_DB_PASSWORD phrame_dev Local Docker dev database password for Postgres/MariaDB overlays

Process environment variables always take precedence over values in .env.

Production Deployment Checklist

  • Web root isolation: Point your web server document root strictly to public/ (never expose the project root, .env, var/, vendor/, or config/). Deny dotfiles (location ~ /\. { deny all; }).
  • Disable debug diagnostics: Keep PHRAME_DEBUG=0 in production so internal 500 errors return safe RFC 9457 Problem Details without stack traces.
  • Secure Admin UI cookies over HTTPS: Set PHRAME_ADMIN_SECURE_COOKIE=1 in HTTPS production deployments (especially behind TLS-terminating reverse proxies) so /admin session cookies always carry the Secure attribute.
  • Multi-worker database: Use PostgreSQL (pgsql://...) or MySQL/MariaDB (mysql://...) via PHRAME_DSN for concurrent multi-worker deployments instead of local SQLite.
  • Authorization header forwarding: Under Nginx + PHP-FPM, forward the Authorization header cleanly with fastcgi_param HTTP_AUTHORIZATION $http_authorization if_not_empty; so public endpoints remain accessible and Bearer Agent Tokens authenticate properly.
  • Least-privilege tokens & secret hygiene: Issue narrowly scoped AI Agent Tokens per client, rotate/revoke unused tokens, and never commit .env, SQLite files (var/*.sqlite), or real credentials to version control.

Verification & Quality Checks

Run the full local verification suite (PHP syntax lint across src/, modules/, tests/, public/, config/, bin/, PHPStan level max, PER-CS check, PHPUnit) plus bin/dev syntax validation:

bash -n bin/dev && composer check

License

MIT