Recipes · v0.8.3.8.4

Developer Recipes

Practical PHP-only workflows for building with Monarch.

Recipe

Compose a Landing Page

Use a Page Composition Guide to create a route, add page data, choose the landing template, and compose Hero, Feature Grid, Statistics, Image, and CTA patterns.

  1. Open the relevant Page Composition Guide.
  2. Create a thin route controller.
  3. Add data/pages/example.php.
  4. Set template to landing.
  5. Add sections using hero, feature-grid, statistics, images, and cta-banner.

Recipe

Add a New Page

Use the PHP-only page data architecture so the route file remains minimal and future-MySQL-ready.

  1. Copy a thin route controller.
  2. Create a matching data/pages file.
  3. Assign nav_key, title, template, and sections.
  4. Add navigation only when the page should appear publicly.

Recipe

Add a New Component

Create the PHP partial, add component metadata, document tokens/classes, and add a library route if it should be public.

  1. Create components/family/name.php.
  2. Add data/components metadata.
  3. Add component library gallery route.
  4. Run verification dashboard checks.

Recipe

Add a New Pattern

Patterns are larger assemblies that coordinate components and tokens.

  1. Create patterns/name.php.
  2. Add metadata in data/patterns.
  3. List components used.
  4. Render through monarch_render_pattern().

Recipe

Change the Color System

Edit design palette and theme files, not generated CSS output.

  1. Edit design/palette.php.
  2. Map roles in design/theme.php.
  3. Review token browser.
  4. Run token audit.

Recipe

Change the Font System

Update typography roles and font loading from the central typography configuration.

  1. Edit design/typography.php.
  2. Install local WOFF2 files if using local mode.
  3. Review Style Guide typography.
  4. Run route render checks.

Recipe

Add a Navigation Item

Edit the shared navigation configuration rather than hard-coding links into headers.

  1. Edit config/navigation.php.
  2. Use site_url() or monarch_url() in templates when needed.
  3. Run local-link verification.

Recipe

Verify a Release

Use the verification dashboard checklist before packaging a new ZIP.

  1. Lint PHP files.
  2. Render representative routes.
  3. Audit tokens.
  4. Audit links.
  5. Create verification markdown.

Recipe

Add an Image the Monarch Way

Use image roles and helpers rather than hard-coding placeholder image paths in page markup.

  1. Choose a role from the Image Library.
  2. Use monarch_image_frame() or monarch_image().
  3. Set context to universal or monarch.
  4. Choose color or grayscale mode only when the default is not appropriate.
  5. Verify fallback behavior.