Configuration
Complete reference for all configuration options
Configuration
After publishing the config file, you will find all options in config/oi-laravel-ts.php.
output_path
Type: string — Default: resource_path('js/types/interfaces.ts')
The path where the generated TypeScript file is written.
'output_path' => resource_path('js/types/interfaces.ts'),Used only in single output mode.
output_mode
Type: string — Default: 'single'
Controls how the generated interfaces are written to disk:
'single'— every interface is concatenated into one file atoutput_path.'multiple'— each interface is written to its own kebab-cased file inoutput_dir, alongside anindex.tsbarrel. Every file imports exactly the interfaces it references.
'output_mode' => 'single',See Multi-file output for the full layout and import behavior.
output_dir
Type: string — Default: resource_path('js/types')
Target directory for the generated files when output_mode is 'multiple'.
Ignored in single mode.
'output_dir' => resource_path('js/types'),with_counts
Type: bool — Default: true
When enabled, the generator adds an optional {relation}_count field for every HasMany and BelongsToMany relationship.
'with_counts' => true,With true, a User with a posts relationship also receives posts_count?: number.
with_json_ld
Type: bool — Default: false
Adds a JsonLdRawNode interface to the generated file, useful when working with JSON-LD data structures.
'with_json_ld' => false,discover_related_models
Type: bool — Default: true
When enabled, any model targeted by a relationship is added to the schema even if it lives outside app/Models. This is essential when using packages like spatie/laravel-permission — the Role and Permission models are discovered via relationship detection and get their own interfaces.
'discover_related_models' => true,save_schema
Type: bool — Default: false
Saves an intermediate schema.json file next to the output file. Useful for debugging when the generated TypeScript doesn't look right.
'save_schema' => false,props_with_types
Type: array — Default: []
Override the inferred TypeScript type for specific model properties.
'props_with_types' => [
'User' => [
'status' => "'active' | 'inactive' | 'banned'",
],
],dataobject_namespaces
Type: array — Default: ['App\\DataObjects']
Namespaces searched when resolving short DataObject class names found in PHPDoc annotations (e.g. @var Address). The list is iterated in order; the first matching class wins.
'dataobject_namespaces' => [
'App\\DataObjects',
'App\\ValueObjects',
],discover_all_dataobjects
Type: bool — Default: false
When true, every DataObject under dataobject_namespaces is emitted as an
I{ClassName} interface, even if no model cast references it. Namespaces are
scanned recursively and nested DataObjects are resolved automatically. Two
classes resolving to the same short name throw a
DataObjectNameCollisionException.
When false (default), a DataObject is only generated when it is reachable from
a model cast. See DataObjects for details.
'discover_all_dataobjects' => false,data_namespaces
Type: array — Default: []
Namespaces holding spatie/laravel-data style Data Transfer Objects (DTOs). Every
class found under these namespaces that has a constructor with promoted
properties is emitted as an I{ClassName} interface (e.g.
App\Data\Knowledge\KnowledgeData becomes IKnowledgeData).
Detection is structural — no dependency on spatie/laravel-data is required.
Property names are kept verbatim (camelCase), backed enums become literal unions
('draft' | 'published'), nested DTOs become I{Name}, and typed arrays
declared through a property @var Foo[] annotation become IFoo[]. Namespaces
are scanned recursively and nested DTOs are resolved automatically.
This is fully opt-in: an empty list keeps the previous behavior unchanged. It is
a distinct mechanism from dataobject_namespaces, which resolves value objects
by short name through the fromArray()/toArray() contract.
'data_namespaces' => [
'App\\Data',
],data_replaces_model
Type: bool — Default: false
When false (default), DTO interfaces are emitted in addition to the Eloquent
model interfaces — IKnowledge (model) and IKnowledgeData (DTO) coexist.
When true, any model mapped to a DTO no longer emits its Eloquent I{Model}
interface: the DTO becomes the single source of truth for that model's shape. The
model is identified from the first parameter of the DTO's fromModel() factory,
or from data_for_model.
Note: with this enabled, a relationship on another model that points to a replaced model will reference an interface that is no longer generated.
'data_replaces_model' => false,data_for_model
Type: array — Default: []
Explicit model => DTO overrides, used when a DTO has no fromModel(Model $m)
factory to introspect, or to force a specific pairing.
'data_for_model' => [
App\Models\Knowledge::class => App\Data\Knowledge\KnowledgeData::class,
],excluded_namespaces
Type: array — Default: []
Models whose fully-qualified class name begins with one of these namespace prefixes are excluded entirely from the generated schema — even when they are reached through a relationship. Relationship fields that point to an excluded model are also stripped from all other interfaces.
'excluded_namespaces' => [
'OiLab\\Prestashop\\Models',
],This is useful when a third-party package registers models that you do not want to expose as TypeScript interfaces.
See Namespace filters for full examples.
extended_namespaces
Type: array — Default: []
Models in these namespaces do not generate standalone interfaces. Instead, for each such model whose short class name matches a base model already in the schema, an additional extension interface is emitted:
export interface IUserExtended extends IUser { ... }'extended_namespaces' => [
'OiLab\\Prestashop\\Extended\\Models',
],This is useful for package-specific variants of your app models that add extra typed fields without replacing the base interface.
See Namespace filters for full examples.
custom_props
Type: array — Default: []
Add virtual properties to models — properties that don't exist in the database schema but are present in the serialized JSON (computed attributes, appended properties, etc.).
'custom_props' => [
// Add properties to a specific model
'User' => [
'full_name' => 'string',
'avatar_url' => 'string | null',
],
// Reference an external TypeScript type (format: 'path|TypeName')
'Page' => [
'layout' => '@/types/layouts|LayoutConfig',
],
],The external type format @/types/layouts|LayoutConfig generates an import statement:
import { LayoutConfig } from '@/types/layouts';In multiple output mode this import is re-emitted in each generated file that
uses the type. See Multi-file output.