{"id":47880040,"url":"https://github.com/yannelli/schematic","last_synced_at":"2026-04-04T01:43:14.526Z","repository":{"id":345440227,"uuid":"1185809133","full_name":"yannelli/schematic","owner":"yannelli","description":"Schematic is a templating engine for Laravel that generates JSON Schema definitions from your templates.","archived":false,"fork":false,"pushed_at":"2026-03-19T22:24:46.000Z","size":118,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-04T01:43:12.339Z","etag":null,"topics":["ai","laravel","laravel-package","structured-outputs","templating-engine"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yannelli.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-19T00:55:30.000Z","updated_at":"2026-03-19T22:24:49.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/yannelli/schematic","commit_stats":null,"previous_names":["yannelli/schematic"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/yannelli/schematic","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yannelli%2Fschematic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yannelli%2Fschematic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yannelli%2Fschematic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yannelli%2Fschematic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yannelli","download_url":"https://codeload.github.com/yannelli/schematic/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yannelli%2Fschematic/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31384845,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T01:22:39.193Z","status":"ssl_error","status_checked_at":"2026-04-04T01:22:33.970Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","laravel","laravel-package","structured-outputs","templating-engine"],"created_at":"2026-04-04T01:43:13.885Z","updated_at":"2026-04-04T01:43:14.515Z","avatar_url":"https://github.com/yannelli.png","language":"PHP","readme":"![GitHub branch check runs](https://img.shields.io/github/check-runs/yannelli/schematic/main?style=flat-square) ![Packagist Version](https://img.shields.io/packagist/v/yannelli/schematic?style=flat-square) \n\n# Schematic\n\n- [Introduction](#introduction)\n- [Installation](#installation)\n- [Configuration](#configuration)\n    - [JSON Schema Defaults](#json-schema-defaults)\n    - [Custom Models](#custom-models)\n- [Creating Templates](#creating-templates)\n    - [Adding Sections](#adding-sections)\n    - [Defining Fields](#defining-fields)\n    - [Array \u0026 Object Fields](#array-and-object-fields)\n- [Ephemeral Templates](#ephemeral-templates)\n    - [Creating Ephemeral Templates](#creating-ephemeral-templates)\n    - [Ephemeral Schema \u0026 Rendering](#ephemeral-schema-and-rendering)\n- [JSON Schema Generation](#json-schema-generation)\n    - [Template Schemas](#template-schemas)\n    - [Section Schemas](#section-schemas)\n    - [Using With Anthropic](#using-with-anthropic)\n    - [Using With OpenAI](#using-with-openai)\n- [Managing Sections](#managing-sections)\n    - [Enabling \u0026 Disabling Sections](#enabling-and-disabling-sections)\n    - [Reordering Sections](#reordering-sections)\n    - [Iterating Sections](#iterating-sections)\n    - [Adding \u0026 Removing Fields](#adding-and-removing-fields)\n- [Rendering Templates](#rendering-templates)\n    - [Full Template Rendering](#full-template-rendering)\n    - [Previewing With Examples](#previewing-with-examples)\n- [Template Syntax](#template-syntax)\n- [Custom Macros](#custom-macros)\n- [Extending Models](#extending-models)\n- [License](#license)\n\n\u003ca name=\"introduction\"\u003e\u003c/a\u003e\n## Introduction\n\nSchematic is a templating engine for Laravel that generates JSON Schema definitions from your templates. It is designed for use with LLM structured output APIs such as those provided by OpenAI and Anthropic, allowing you to define templates with typed fields and automatically produce valid JSON Schema for tool use and structured responses. Templates can be persisted to the database or created as [ephemeral (in-memory) templates](#ephemeral-templates) for on-the-fly use without any database overhead.\n\n\u003ca name=\"installation\"\u003e\u003c/a\u003e\n## Installation\n\nInstall Schematic via Composer:\n\n```bash\ncomposer require yannelli/schematic\n```\n\nAfter installing, publish and run the migrations:\n\n```bash\nphp artisan vendor:publish --tag=schematic-migrations\nphp artisan migrate\n```\n\nYou may optionally publish the configuration file:\n\n```bash\nphp artisan vendor:publish --tag=schematic-config\n```\n\n\u003ca name=\"configuration\"\u003e\u003c/a\u003e\n## Configuration\n\nThe Schematic configuration file is located at `config/schematic.php`. Each configuration option is documented below.\n\n\u003ca name=\"json-schema-defaults\"\u003e\u003c/a\u003e\n### JSON Schema Defaults\n\nThe `schema` options control the defaults used when generating JSON Schema output:\n\n| Option | Environment Variable | Default | Description |\n|---|---|---|---|\n| `schema.draft` | — | `https://json-schema.org/draft/2020-12/schema` | The JSON Schema draft URI included in schema documents. |\n| `schema.strict` | — | `true` | When enabled, all generated schemas include `additionalProperties: false`. |\n\n\u003ca name=\"custom-models\"\u003e\u003c/a\u003e\n### Custom Models\n\nIf you need to extend the base Schematic models, you may specify your custom model classes in the `models` configuration array. See [Extending Models](#extending-models) for details.\n\n\u003ca name=\"creating-templates\"\u003e\u003c/a\u003e\n## Creating Templates\n\nTo create a new template, use the `Schematic` facade's `create` method:\n\n```php\nuse Yannelli\\Schematic\\Facades\\Schematic;\n\n$template = Schematic::create(\n    slug: 'psychiatric-evaluation',\n    name: 'Psychiatric Evaluation Note',\n    description: 'Standard psychiatric evaluation template for initial patient encounters',\n);\n```\n\n\u003ca name=\"adding-sections\"\u003e\u003c/a\u003e\n### Adding Sections\n\nOnce a template has been created, you may add sections to it using the `addSection` method. Each section defines a portion of the template with its own content, fields, and optional example data:\n\n```php\n$template-\u003eaddSection(\n    slug: 'chief-complaint',\n    name: 'Chief Complaint',\n    description: 'The primary reason the patient is seeking treatment',\n    content: 'Chief Complaint: {{ complaint }}',\n    fields: [\n        [\n            'name' =\u003e 'complaint',\n            'type' =\u003e 'string',\n            'description' =\u003e 'The patient\\'s primary complaint in their own words',\n            'required' =\u003e true,\n            'nullable' =\u003e false,\n        ],\n    ],\n    examples: [\n        'complaint' =\u003e 'Patient reports increasing anxiety over the past 3 months',\n    ],\n);\n```\n\n\u003ca name=\"defining-fields\"\u003e\u003c/a\u003e\n### Defining Fields\n\nEach field in a section requires a `name`, `type`, and `description`. You may also specify whether the field is `required` or `nullable`:\n\n```php\n$template-\u003eaddSection(\n    slug: 'mental-status-exam',\n    name: 'Mental Status Exam',\n    description: 'Structured mental status examination findings',\n    content: \u003c\u003c\u003c'TPL'\n## Mental Status Exam\n- Appearance: {{ appearance }}\n- Mood: {{ mood }}\n- Affect: {{ affect }}\n- Thought Process: {{ thought_process }}\n@if(suicidal_ideation)\n- **Suicidal Ideation: {{ suicidal_ideation }}**\n@endif\nTPL,\n    fields: [\n        ['name' =\u003e 'appearance', 'type' =\u003e 'string', 'description' =\u003e 'General appearance and grooming'],\n        ['name' =\u003e 'mood', 'type' =\u003e 'string', 'description' =\u003e 'Patient\\'s self-reported mood'],\n        ['name' =\u003e 'affect', 'type' =\u003e 'enum', 'description' =\u003e 'Observed affect', 'enum' =\u003e ['flat', 'blunted', 'constricted', 'full', 'labile']],\n        ['name' =\u003e 'thought_process', 'type' =\u003e 'string', 'description' =\u003e 'Organization and flow of thoughts'],\n        ['name' =\u003e 'suicidal_ideation', 'type' =\u003e 'string', 'description' =\u003e 'Details of suicidal ideation if present', 'required' =\u003e false, 'nullable' =\u003e true],\n    ],\n    examples: [\n        'appearance' =\u003e 'Well-groomed, appropriately dressed, good hygiene',\n        'mood' =\u003e 'Anxious',\n        'affect' =\u003e 'constricted',\n        'thought_process' =\u003e 'Linear and goal-directed',\n        'suicidal_ideation' =\u003e null,\n    ],\n);\n```\n\nWhen a field's `type` is set to `enum`, you should provide an `enum` array containing the allowed values. Fields are required by default; set `required` to `false` and `nullable` to `true` for optional fields.\n\n\u003ca name=\"array-and-object-fields\"\u003e\u003c/a\u003e\n### Array \u0026 Object Fields\n\nFor more complex data structures, you may define fields with `array` and `object` types. Array fields require an `items` key describing the structure of each element:\n\n```php\n$template-\u003eaddSection(\n    slug: 'diagnoses',\n    name: 'Diagnoses',\n    content: \u003c\u003c\u003c'TPL'\n## Diagnoses\n@foreach(diagnoses as dx)\n- {{ dx.code }}: {{ dx.description }}\n@endforeach\nTPL,\n    fields: [\n        [\n            'name' =\u003e 'diagnoses',\n            'type' =\u003e 'array',\n            'description' =\u003e 'List of ICD-10 diagnoses',\n            'items' =\u003e [\n                'type' =\u003e 'object',\n                'properties' =\u003e [\n                    'code' =\u003e ['type' =\u003e 'string', 'description' =\u003e 'ICD-10 code'],\n                    'description' =\u003e ['type' =\u003e 'string', 'description' =\u003e 'Diagnosis description'],\n                ],\n                'required' =\u003e ['code', 'description'],\n            ],\n        ],\n    ],\n    examples: [\n        'diagnoses' =\u003e [\n            ['code' =\u003e 'F41.1', 'description' =\u003e 'Generalized anxiety disorder'],\n            ['code' =\u003e 'F32.1', 'description' =\u003e 'Major depressive disorder, single episode, moderate'],\n        ],\n    ],\n);\n```\n\n\u003ca name=\"ephemeral-templates\"\u003e\u003c/a\u003e\n## Ephemeral Templates\n\nEphemeral templates are in-memory templates that are **not persisted to the database**. They are useful for one-off or dynamic templates that you build at runtime — no migrations or database queries required.\n\nEphemeral templates support the same core features as database-backed templates: sections, fields, JSON Schema generation, rendering, and previewing.\n\n\u003ca name=\"creating-ephemeral-templates\"\u003e\u003c/a\u003e\n### Creating Ephemeral Templates\n\nUse the `ephemeral` method on the `Schematic` facade to create an in-memory template:\n\n```php\nuse Yannelli\\Schematic\\Facades\\Schematic;\n\n$template = Schematic::ephemeral(\n    slug: 'intake-form',\n    name: 'Patient Intake Form',\n    description: 'A quick intake form built on the fly',\n);\n\n$template-\u003eaddSection(\n    slug: 'demographics',\n    name: 'Demographics',\n    content: '{{ patient_name }}, Age: {{ age }}',\n    fields: [\n        ['name' =\u003e 'patient_name', 'type' =\u003e 'string', 'description' =\u003e 'Full name'],\n        ['name' =\u003e 'age', 'type' =\u003e 'integer', 'description' =\u003e 'Patient age'],\n    ],\n    examples: ['patient_name' =\u003e 'Jane Doe', 'age' =\u003e 34],\n);\n```\n\nYou may also create ephemeral templates directly via the `EphemeralTemplate` class:\n\n```php\nuse Yannelli\\Schematic\\Ephemeral\\EphemeralTemplate;\n\n$template = EphemeralTemplate::make('quick-note', 'Quick Note');\n$section = $template-\u003eaddSection('body', 'Body', content: '{{ note }}');\n$section-\u003eaddField('note', 'string', 'The note content');\n```\n\nSections on ephemeral templates support the same fluent methods as database-backed sections, including `addField`, `removeField`, `enable`, `disable`, and `setExamples`. All mutations happen in memory.\n\n\u003ca name=\"ephemeral-schema-and-rendering\"\u003e\u003c/a\u003e\n### Ephemeral Schema \u0026 Rendering\n\nEphemeral templates generate JSON Schema and render content exactly like their database-backed counterparts:\n\n```php\n// JSON Schema generation\n$schema = $template-\u003etoJsonSchema();\n$doc = $template-\u003etoJsonSchemaDocument();\n$sectionSchema = $template-\u003esectionSchema('demographics');\n\n// Rendering with data\n$output = $template-\u003erender([\n    'demographics' =\u003e ['patient_name' =\u003e 'Alice Smith', 'age' =\u003e 28],\n]);\n\n// Preview using example data\n$preview = $template-\u003epreview();\n```\n\nSection management works identically — you can iterate, reorder, enable, and disable sections:\n\n```php\n$template-\u003esection('demographics')-\u003edisable();\n$template-\u003ereorderSections(['body', 'demographics']);\n\nforeach ($template-\u003eiterateSections() as $section) {\n    // Only enabled sections\n}\n```\n\n\u003ca name=\"json-schema-generation\"\u003e\u003c/a\u003e\n## JSON Schema Generation\n\nSchematic generates JSON Schema definitions from your templates, ready for use with LLM structured output APIs.\n\n\u003ca name=\"template-schemas\"\u003e\u003c/a\u003e\n### Template Schemas\n\nTo generate a JSON Schema for an entire template, use the `toJsonSchema` method on a template instance. For a full schema document including the `$schema` header, use `toJsonSchemaDocument`:\n\n```php\nuse Yannelli\\Schematic\\Facades\\Schematic;\n\n// Schema object\n$schema = $template-\u003etoJsonSchema();\n\n// Full document with $schema header\n$doc = $template-\u003etoJsonSchemaDocument();\n\n// Via facade\n$schema = Schematic::schema('psychiatric-evaluation');\n$doc = Schematic::schemaDocument('psychiatric-evaluation');\n```\n\n\u003ca name=\"section-schemas\"\u003e\u003c/a\u003e\n### Section Schemas\n\nYou may also generate a schema for a single section:\n\n```php\n$mseSchema = $template-\u003esectionSchema('mental-status-exam');\n\n// Via facade\n$sectionSchema = Schematic::sectionSchema('psychiatric-evaluation', 'chief-complaint');\n```\n\nThe generated schema for the `mental-status-exam` section would look like the following:\n\n```json\n{\n  \"type\": \"object\",\n  \"properties\": {\n    \"appearance\": {\n      \"type\": \"string\",\n      \"description\": \"General appearance and grooming\"\n    },\n    \"mood\": {\n      \"type\": \"string\",\n      \"description\": \"Patient's self-reported mood\"\n    },\n    \"affect\": {\n      \"type\": \"string\",\n      \"enum\": [\"flat\", \"blunted\", \"constricted\", \"full\", \"labile\"],\n      \"description\": \"Observed affect\"\n    },\n    \"thought_process\": {\n      \"type\": \"string\",\n      \"description\": \"Organization and flow of thoughts\"\n    },\n    \"suicidal_ideation\": {\n      \"type\": [\"string\", \"null\"],\n      \"description\": \"Details of suicidal ideation if present\"\n    }\n  },\n  \"required\": [\"appearance\", \"mood\", \"affect\", \"thought_process\", \"suicidal_ideation\"],\n  \"description\": \"Structured mental status examination findings\",\n  \"additionalProperties\": false\n}\n```\n\n\u003ca name=\"using-with-anthropic\"\u003e\u003c/a\u003e\n### Using With Anthropic\n\nTo use a Schematic template with the Anthropic API, pass the generated schema as a tool's `input_schema`:\n\n```php\nuse Anthropic\\Anthropic;\nuse Yannelli\\Schematic\\Facades\\Schematic;\n\n$schema = Schematic::schema('psychiatric-evaluation');\n\n$response = Anthropic::messages()-\u003ecreate([\n    'model' =\u003e 'claude-sonnet-4-20250514',\n    'max_tokens' =\u003e 4096,\n    'messages' =\u003e [\n        ['role' =\u003e 'user', 'content' =\u003e $transcriptText],\n    ],\n    'tools' =\u003e [\n        [\n            'name' =\u003e 'generate_note',\n            'description' =\u003e 'Generate a structured psychiatric evaluation note',\n            'input_schema' =\u003e $schema,\n        ],\n    ],\n    'tool_choice' =\u003e ['type' =\u003e 'tool', 'name' =\u003e 'generate_note'],\n]);\n```\n\n\u003ca name=\"using-with-openai\"\u003e\u003c/a\u003e\n### Using With OpenAI\n\nWhen using OpenAI's structured output, pass the schema document to the `response_format` parameter:\n\n```php\nuse OpenAI\\Laravel\\Facades\\OpenAI;\nuse Yannelli\\Schematic\\Facades\\Schematic;\n\n$schema = Schematic::schemaDocument('psychiatric-evaluation');\n\n$response = OpenAI::chat()-\u003ecreate([\n    'model' =\u003e 'gpt-4o',\n    'messages' =\u003e [\n        ['role' =\u003e 'user', 'content' =\u003e $transcriptText],\n    ],\n    'response_format' =\u003e [\n        'type' =\u003e 'json_schema',\n        'json_schema' =\u003e [\n            'name' =\u003e 'psychiatric_evaluation',\n            'strict' =\u003e true,\n            'schema' =\u003e $schema,\n        ],\n    ],\n]);\n```\n\n\u003e [!NOTE]\n\u003e OpenAI's structured output requires the full schema document (via `schemaDocument`), while Anthropic's tool use expects the schema object (via `schema`).\n\n\u003ca name=\"managing-sections\"\u003e\u003c/a\u003e\n## Managing Sections\n\n\u003ca name=\"enabling-and-disabling-sections\"\u003e\u003c/a\u003e\n### Enabling \u0026 Disabling Sections\n\nYou may enable or disable individual sections on a template. Disabled sections are excluded from both schema generation and rendering:\n\n```php\n$template-\u003esection('diagnoses')-\u003edisable();\n\n// Only enabled sections are included\n$schema = $template-\u003etoJsonSchema();\n$output = $template-\u003erender($data);\n\n$template-\u003esection('diagnoses')-\u003eenable();\n```\n\n\u003ca name=\"reordering-sections\"\u003e\u003c/a\u003e\n### Reordering Sections\n\nTo change the order in which sections appear, pass an array of section slugs to the `reorderSections` method:\n\n```php\n$template-\u003ereorderSections([\n    'chief-complaint',\n    'diagnoses',\n    'mental-status-exam',\n]);\n```\n\n\u003ca name=\"iterating-sections\"\u003e\u003c/a\u003e\n### Iterating Sections\n\nTo iterate over a template's sections, use the `iterateSections` method. By default, only enabled sections are returned in their defined order:\n\n```php\nforeach ($template-\u003eiterateSections() as $section) {\n    echo \"{$section-\u003ename}: \" . ($section-\u003eis_enabled ? 'ON' : 'OFF') . \"\\n\";\n    echo json_encode($section-\u003etoJsonSchema(), JSON_PRETTY_PRINT) . \"\\n\\n\";\n}\n```\n\nTo include disabled sections, use `iterateAllSections`:\n\n```php\nforeach ($template-\u003eiterateAllSections() as $section) {\n    // ...\n}\n```\n\n\u003ca name=\"adding-and-removing-fields\"\u003e\u003c/a\u003e\n### Adding \u0026 Removing Fields\n\nYou may add or remove fields from an existing section:\n\n```php\n$section = $template-\u003esection('chief-complaint');\n\n$section-\u003eaddField(\n    name: 'onset',\n    type: 'string',\n    description: 'When symptoms first appeared',\n    required: false,\n);\n\n$section-\u003eremoveField('onset');\n```\n\n\u003ca name=\"rendering-templates\"\u003e\u003c/a\u003e\n## Rendering Templates\n\n\u003ca name=\"full-template-rendering\"\u003e\u003c/a\u003e\n### Full Template Rendering\n\nTo render a template with data, pass an associative array keyed by section slug to the `render` method:\n\n```php\n$data = [\n    'chief-complaint' =\u003e [\n        'complaint' =\u003e 'Increasing anxiety and panic attacks',\n    ],\n    'mental-status-exam' =\u003e [\n        'appearance' =\u003e 'Casually dressed, fidgeting',\n        'mood' =\u003e 'Anxious',\n        'affect' =\u003e 'constricted',\n        'thought_process' =\u003e 'Circumstantial at times',\n    ],\n    'diagnoses' =\u003e [\n        'diagnoses' =\u003e [\n            ['code' =\u003e 'F41.0', 'description' =\u003e 'Panic disorder'],\n        ],\n    ],\n];\n\necho $template-\u003erender($data);\n\n// Via facade\necho Schematic::render('psychiatric-evaluation', $data);\n```\n\n\u003ca name=\"previewing-with-examples\"\u003e\u003c/a\u003e\n### Previewing With Examples\n\nWhen you have defined example data on your sections, you may preview the rendered output without providing data manually. To set example data on a section, use the `setExamples` method:\n\n```php\n$template-\u003esection('chief-complaint')-\u003esetExamples([\n    'complaint' =\u003e 'Patient reports difficulty sleeping for the past 2 weeks',\n]);\n```\n\nTo preview a single section or the entire template using its example data:\n\n```php\n// Preview a single section\necho $template-\u003esection('chief-complaint')-\u003epreview();\n\n// Preview the entire template\necho $template-\u003epreview();\n\n// Via facade\necho Schematic::preview('psychiatric-evaluation');\n```\n\n\u003ca name=\"template-syntax\"\u003e\u003c/a\u003e\n## Template Syntax\n\nSchematic provides a lightweight template syntax for defining section content:\n\n| Syntax | Description |\n|---|---|\n| `{{ variable }}` | Variable substitution. |\n| `{{ nested.key }}` | Dot-notation access for nested values. |\n| `@if(var) ... @endif` | Conditional block; renders content only when `var` is truthy. |\n| `@if(var) ... @else ... @endif` | Conditional with an else branch. |\n| `@foreach(items as item) ... @endforeach` | Iterate over an array. |\n| `@macroName(\"arg1\", \"arg2\")` | Invoke a registered custom macro. |\n\n\u003ca name=\"custom-macros\"\u003e\u003c/a\u003e\n## Custom Macros\n\nYou may register custom macros to extend the template syntax. Macros should be registered in a service provider's `boot` method:\n\n```php\nuse Yannelli\\Schematic\\Facades\\Schematic;\n\npublic function boot(): void\n{\n    Schematic::macro('component', fn (string $name) =\u003e view(\"components.{$name}\")-\u003erender());\n    Schematic::macro('timestamp', fn () =\u003e now()-\u003etoDateTimeString());\n    Schematic::macro('badge', fn (string $label, string $color) =\u003e \"\u003cspan class=\\\"badge badge-{$color}\\\"\u003e{$label}\u003c/span\u003e\");\n}\n```\n\nOnce registered, macros may be used in any template content:\n\n```\n@component(\"vital-signs\")\nGenerated at: @timestamp()\nStatus: @badge(\"Active\", \"green\")\n```\n\n\u003ca name=\"extending-models\"\u003e\u003c/a\u003e\n## Extending Models\n\nIf you need to add custom behavior to the Schematic models, you may extend the base `Template` and `Section` classes and register them in the configuration:\n\n```php\n// config/schematic.php\n'models' =\u003e [\n    'template' =\u003e App\\Models\\CustomTemplate::class,\n    'section' =\u003e App\\Models\\CustomSection::class,\n],\n```\n\nYour custom models should extend the corresponding base classes:\n\n```php\nuse Yannelli\\Schematic\\Models\\Template;\n\nclass CustomTemplate extends Template\n{\n    // Add your custom logic\n}\n```\n\n\u003ca name=\"credis\"\u003e\u003c/a\u003e\n\n## Credits\n- [Ryan Yannelli](https://ryanyannelli.com)\n  - [Website](https://ryanyannelli.com)\n  - [GitHub](https://github.com/yannelli)\n- [Nextvisit AI](https://nextvisit.ai)\n- [All Contributors](../../contributors)\n\n\n\u003ca name=\"license\"\u003e\u003c/a\u003e\n## License\n\nSchematic is open-sourced software licensed under the [MIT license](LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyannelli%2Fschematic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyannelli%2Fschematic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyannelli%2Fschematic/lists"}