Download the PHP package yannelli/schematic without Composer

On this page you can find all versions of the php package yannelli/schematic. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package schematic

GitHub branch check runs Packagist Version

Schematic

Introduction

Schematic 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 for on-the-fly use without any database overhead.

Installation

Install Schematic via Composer:

After installing, publish and run the migrations:

You may optionally publish the configuration file:

Configuration

The Schematic configuration file is located at config/schematic.php. Each configuration option is documented below.

JSON Schema Defaults

The schema options control the defaults used when generating JSON Schema output:

Option Environment Variable Default Description
schema.draft https://json-schema.org/draft/2020-12/schema The JSON Schema draft URI included in schema documents.
schema.strict true When enabled, all generated schemas include additionalProperties: false.

Custom Models

If you need to extend the base Schematic models, you may specify your custom model classes in the models configuration array. See Extending Models for details.

Creating Templates

To create a new template, use the Schematic facade's create method:

Adding Sections

Once 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:

Defining Fields

Each field in a section requires a name, type, and description. You may also specify whether the field is required or nullable:

When 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.

Array & Object Fields

For 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:

Ephemeral Templates

Ephemeral 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.

Ephemeral templates support the same core features as database-backed templates: sections, fields, JSON Schema generation, rendering, and previewing.

Creating Ephemeral Templates

Use the ephemeral method on the Schematic facade to create an in-memory template:

You may also create ephemeral templates directly via the EphemeralTemplate class:

Sections on ephemeral templates support the same fluent methods as database-backed sections, including addField, removeField, enable, disable, and setExamples. All mutations happen in memory.

Ephemeral Schema & Rendering

Ephemeral templates generate JSON Schema and render content exactly like their database-backed counterparts:

Section management works identically — you can iterate, reorder, enable, and disable sections:

JSON Schema Generation

Schematic generates JSON Schema definitions from your templates, ready for use with LLM structured output APIs.

Template Schemas

To 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:

Section Schemas

You may also generate a schema for a single section:

The generated schema for the mental-status-exam section would look like the following:

Using With Anthropic

To use a Schematic template with the Anthropic API, pass the generated schema as a tool's input_schema:

Using With OpenAI

When using OpenAI's structured output, pass the schema document to the response_format parameter:

[!NOTE] OpenAI's structured output requires the full schema document (via schemaDocument), while Anthropic's tool use expects the schema object (via schema).

Managing Sections

Enabling & Disabling Sections

You may enable or disable individual sections on a template. Disabled sections are excluded from both schema generation and rendering:

Reordering Sections

To change the order in which sections appear, pass an array of section slugs to the reorderSections method:

Iterating Sections

To iterate over a template's sections, use the iterateSections method. By default, only enabled sections are returned in their defined order:

To include disabled sections, use iterateAllSections:

Adding & Removing Fields

You may add or remove fields from an existing section:

Rendering Templates

Full Template Rendering

To render a template with data, pass an associative array keyed by section slug to the render method:

Previewing With Examples

When 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:

To preview a single section or the entire template using its example data:

Template Syntax

Schematic provides a lightweight template syntax for defining section content:

Syntax Description
{{ variable }} Variable substitution.
{{ nested.key }} Dot-notation access for nested values.
@if(var) ... @endif Conditional block; renders content only when var is truthy.
@if(var) ... @else ... @endif Conditional with an else branch.
@foreach(items as item) ... @endforeach Iterate over an array.
@macroName("arg1", "arg2") Invoke a registered custom macro.

Custom Macros

You may register custom macros to extend the template syntax. Macros should be registered in a service provider's boot method:

Once registered, macros may be used in any template content:

Extending Models

If 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:

Your custom models should extend the corresponding base classes:

Credits

License

Schematic is open-sourced software licensed under the MIT license.


All versions of schematic with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/database Version ^12.0 || ^13.0
illuminate/support Version ^12.0 || ^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package yannelli/schematic contains the following files

Loading the files please wait ...