The problem
LLM structured outputs mean writing JSON Schema by hand for every shape you want back. For one or two endpoints, that’s fine. With dozens of prompts, each with its own response shape, and schemas living apart from the code that uses them, it falls apart. Schemas drift, validation breaks at runtime, and every prompt change turns into a coordinated edit across files.
It happens in reverse, too. Business templates need filling from LLM output, and the template itself should decide what the model returns. A template in one place and a matching schema in another is duplication you’ll regret.
The solution
Schematic is a Laravel templating engine that outputs valid JSON Schema. Define the shape once, in a Schematic template. Then render the filled-in text, or hand the matching schema straight to OpenAI or Anthropic structured-output APIs.
Templates can live in the database, so non-developers can edit them at runtime, or in memory for one-off use. Typed fields (string, integer, boolean, enum, array, object) become typed JSON Schema properties. Conditional blocks, loops, and custom macros handle real business logic without string concatenation. And sections can be turned on, turned off, and reordered without rewriting the template. That matters when an admin UI drives generation.
The origin
Schematic came out of the Nextvisit codebase. Behavioral health documentation has dozens of clinical note shapes (SOAP, DAP, BIRP, addiction-treatment specifics), and each one has to be a valid schema the LLM can target precisely. Keeping schema files beside Blade templates was already painful. A second LLM provider made the duplication intolerable. Schematic is the abstraction that should have existed.
The problem reaches well beyond behavioral health. Anyone building production LLM pipelines
in PHP runs into it. So it’s open source, on Packagist as yannelli/schematic.