Skip to content

Configuration Reference ​

This page lists every option in config/ts-publish.php, grouped by feature. To get your own copy of the file, with a comment on each option, publish it:

bash
php artisan vendor:publish --tag="ts-publish-config"

The *_class keys swap a class in the publishing pipeline. See Abstract Base Classes for what each class must implement.

General Settings ​

Config KeyTypeDefaultDescription
run_after_migratebooltrueRepublish types with --fresh after migrate runs migrations. Set with TS_PUBLISH_RUN_AFTER_MIGRATE. See Publishing After Migrations
output_to_filesbooltrueSetting it to false turns off the post-migration republish. ts:publish writes files on every run unless you pass --preview=true
output_directorystringresources/js/types/dataDirectory where TypeScript files are written
namespace_strip_prefixstring''Prefix removed from class namespaces before they become output paths, such as 'Modules\\'
timestamps_as_dateboolfalseMap date, datetime, and timestamp values, including Carbon instances, to Date instead of string, except a timestamp cast, which is a number
custom_ts_mappingsarray[]Override or extend PHP-to-TypeScript type mappings. See custom_ts_mappings
ts_extends.modelsarray[]Global extends clauses for all models
ts_extends.resourcesarray[]Global extends clauses for all resources
ts_extends.form_requestsarray[]Global extends clauses for all form requests
ts_extends.broadcast_eventsarray[]Global extends clauses for all broadcast events
barrel_writer_classstringBarrelWriterClass that writes barrel index.ts files

custom_ts_mappings ​

Each entry maps a type name to the TypeScript type it publishes, and it wins over the package's own rule for that name:

  • An entry for a cast, such as 'decimal:2', overrides that cast's rule. An entry named like both a cast and a column type, such as 'timestamp' or 'decimal', applies to both, and a 'decimal' entry covers every decimal:N cast.
  • An entry for a column type, such as 'decimal' or 'numeric', publishes that type on every database driver, for the column and for its MIN() and MAX() aggregates. SUM() and AVG() still follow the driver.
  • A DateTime entry is read as the datetime column and cast type, because keys are matched case-insensitively. PHP's DateTime class keeps the object json_encode() writes for it, but a DateTime that a cast class or a new-style accessor returns takes the entry, because Laravel serializes that date as it does a datetime column. An entry for DateTimeImmutable does retype that class.
  • A Carbon\Carbon entry retypes Carbon\Carbon, CarbonInterface and a subclass with no entry of its own, and a date a cast class or a new-style accessor returns whose class has no entry of its own. CarbonImmutable and Illuminate\Support\Carbon, which now() and today() return, follow their own entries, and so do date columns and date casts, such as 'datetime'. A date type with no entry follows timestamps_as_date.
php
'custom_ts_mappings' => [
    'decimal:2' => 'number', // the decimal:2 cast only
    'numeric' => 'number',   // numeric columns, on every driver
],

Models (models.*) ​

Config KeyTypeDefaultDescription
models.enabledbooltrueEnable or disable model publishing
models.namespacestring'models'Not used. The global declaration file names each namespace after the class's PHP namespace, such as app.models
models.relationship_casestring'snake'Case style for relationships: snake, camel, or pascal
models.nullable_relationsbooltrueAppend | null to singular relation types that can be empty, based on each relation type's strategy
models.exclude_hiddenboolfalseOmit Eloquent $hidden attributes from model interfaces, and from resource properties wherever the package derives them from the model. See exclude_hidden and Attribute Filters
models.relation_nullability_maparray[]Override the nullability strategy per relation class: nullable, never, fk, or morph
models.templatestringlaravel-ts-publish::model-splitBlade template for model TypeScript output
models.includedarray[]Only publish these models (empty = all)
models.excludedarray[]Exclude these models from publishing
models.additional_directoriesarray[]Extra directories to search for models. A model that a published model relates to is published without being listed, under the rules in Related Models Outside Your Directories
models.collector_classstringModelsCollectorDiscovers PHP model classes
models.generator_classstringModelGeneratorOrchestrates transforming and writing
models.transformer_classstringModelTransformerConverts PHP class into TypeScript data
models.writer_classstringModelWriterWrites TypeScript model files

Model Metadata (model_metadata.*) ​

A config file published before model metadata existed has no model_metadata block. Nothing breaks without it: every model_metadata key falls back in code to the packaged value, so an older config keeps working until you enable the feature. When you add the block, copy the whole block rather than a single key. The package merges its defaults one level deep, so a partial block replaces the packaged one.

Config KeyTypeDefaultDescription
model_metadata.enabledboolfalsePublish a runtime {model}_meta.ts companion beside each model interface
model_metadata.provider_classstringDefaultModelMetadataProviderThe class whose provide($model) returns each companion's values. It must implement ModelMetadataProvider. The published config shows this key commented out; uncomment it to set your own class
model_metadata.templatestringlaravel-ts-publish::model-metaBlade template for the companion
model_metadata.includedarrayinherits models.includedOnly publish companions for these models (an explicit [] means all)
model_metadata.excludedarrayinherits models.excludedNever publish companions for these models
model_metadata.additional_directoriesarrayinherits models.additional_directoriesExtra directories to search
model_metadata.collector_classstringModelMetadataCollectorDiscovers models for this feature
model_metadata.generator_classstringModelMetadataGeneratorOrchestrates transforming and writing. Must extend the default class
model_metadata.transformer_classstringModelMetadataTransformerBuilds each companion's data from the provider. Must extend the default class
model_metadata.writer_classstringModelMetadataWriterWrites the companion file

Enums (enums.*) ​

Config KeyTypeDefaultDescription
enums.enabledbooltrueEnable or disable enum publishing
enums.namespacestring'enums'Not used. The global declaration file names each namespace after the class's PHP namespace, such as app.enums
enums.method_casestring'camel'Case style for enum methods: snake, camel, or pascal
enums.auto_include_methodsboolfalseInclude all public non-static enum methods without attributes
enums.auto_include_static_methodsboolfalseInclude all public static enum methods without attributes
enums.metadata_enabledbooltrueInclude _cases, _methods, _static metadata on enums
enums.use_tolki_packagebooltrueWrap enums in defineEnum() from @tolki/ts
enums.templatestringlaravel-ts-publish::enumBlade template for enum TypeScript output
enums.includedarray[]Only publish these enums (empty = all)
enums.excludedarray[]Exclude these enums from publishing
enums.additional_directoriesarray[]Extra directories to search for enums
enums.collector_classstringEnumsCollectorDiscovers PHP enum classes
enums.generator_classstringEnumGeneratorOrchestrates transforming and writing
enums.transformer_classstringEnumTransformerConverts PHP enum into TypeScript data
enums.writer_classstringEnumWriterWrites TypeScript enum files

Resources (resources.*) ​

Config KeyTypeDefaultDescription
resources.enabledbooltrueEnable or disable resource publishing
resources.namespacestring'resources'Not used. The global declaration file names each namespace after the class's PHP namespace, such as app.http.resources
resources.templatestringlaravel-ts-publish::resourceBlade template for resource TypeScript output
resources.includedarray[]Only publish these resources (empty = all)
resources.excludedarray[]Exclude these resources from publishing
resources.additional_directoriesarray[]Extra directories to search for resources
resources.collector_classstringResourcesCollectorDiscovers PHP resource classes
resources.generator_classstringResourceGeneratorOrchestrates transforming and writing
resources.transformer_classstringResourceTransformerConverts PHP resource into TypeScript data
resources.writer_classstringResourceWriterWrites TypeScript resource files

Globals (globals.*) ​

See Global Declaration File for what this file contains.

Config KeyTypeDefaultDescription
globals.enabledboolfalseGenerate a global namespace declaration file
globals.output_directorystring''Directory for the global declaration file. Empty uses output_directory
globals.filenamestringlaravel-ts-global.tsFilename for the global declaration file
globals.templatestringlaravel-ts-publish::globalsBlade template for global declaration output
globals.writer_classstringGlobalsWriterWrites global declaration file

JSON (json.*) ​

See JSON Definitions File for the file's format.

Config KeyTypeDefaultDescription
json.enabledboolfalseOutput all definitions as a JSON file
json.filenamestringlaravel-ts-definitions.jsonFilename for the JSON output
json.output_directorystring''Directory for the JSON output. Empty uses output_directory
json.writer_classstringJsonWriterWrites JSON definitions file

Watcher (watcher.*) ​

See Collected Files Manifest for what the file lists.

Config KeyTypeDefaultDescription
watcher.enabledbooltrueOutput collected PHP file paths as JSON (for file watchers)
watcher.filenamestringlaravel-ts-collected-files.jsonFilename for the collected files JSON
watcher.output_directorystring''Directory for the collected files JSON. Empty uses output_directory
watcher.writer_classstringWatcherJsonWriterWrites collected files JSON for watchers

Routes (routes.*) ​

Config KeyTypeDefaultDescription
routes.enabledbooltrueEnable or disable route publishing
routes.method_casingstring'camel'Case style for route method names
routes.output_directorystring''Custom output directory for route files. Empty uses output_directory
routes.onlyarray[]Only publish these routes (empty = all)
routes.exceptarray[]Exclude these routes from publishing
routes.exclude_middlewarearray[]Exclude routes with these middleware
routes.only_namedboolfalseOnly publish named routes
routes.collector_classstringRoutesCollectorDiscovers PHP routes
routes.generator_classstringRouteGeneratorOrchestrates transforming and writing
routes.transformer_classstringRouteTransformerConverts routes into TypeScript data
routes.writer_classstringRouteWriterWrites TypeScript route files
routes.templatestringlaravel-ts-publish::routeBlade template for route output

Form Requests (form_requests.*) ​

Config KeyTypeDefaultDescription
form_requests.enabledbooltrueEnable or disable form request publishing
form_requests.namespacestring'form-requests'Not used. The global declaration file names each namespace after the class's PHP namespace, such as app.http.requests
form_requests.templatestringlaravel-ts-publish::form-requestBlade template for form request TypeScript output
form_requests.output_directorystring''Custom output directory for form request files. Empty uses output_directory
form_requests.includedarray[]Only publish these form requests (empty = all)
form_requests.excludedarray[]Exclude these form requests from publishing
form_requests.additional_directoriesarray[]Extra directories to search for form requests
form_requests.collector_classstringFormRequestsCollectorDiscovers PHP FormRequest classes
form_requests.generator_classstringFormRequestGeneratorOrchestrates transforming and writing
form_requests.transformer_classstringFormRequestTransformerConverts PHP FormRequest into TypeScript data
form_requests.writer_classstringFormRequestWriterWrites TypeScript form request files
form_requests.analyzer_classstringFormRequestRulesAnalyzerResolves rules(), and types validated('key') in Inertia page props

form_requests.analyzer_class has no line in the published config file. Add the key to the form_requests block to point it at your own class. The same class also types $request->validated('key') in Inertia page props, so swapping it changes those types too.

Broadcast Channels (broadcast_channels.*) ​

Config KeyTypeDefaultDescription
broadcast_channels.enabledbooltrueEnable or disable broadcast channel publishing
broadcast_channels.filenamestringbroadcast-channels.tsFilename for the generated channels file
broadcast_channels.templatestringlaravel-ts-publish::broadcast-channelsBlade template for the channels output
broadcast_channels.output_directorystring''Custom output directory for the channels file. Empty uses output_directory
broadcast_channels.collector_classstringBroadcastChannelsCollectorDiscovers registered channel names
broadcast_channels.writer_classstringBroadcastChannelsWriterWrites the broadcast-channels.ts file

Broadcast Events (broadcast_events.*) ​

Config KeyTypeDefaultDescription
broadcast_events.enabledbooltrueEnable or disable broadcast event publishing
broadcast_events.index_filenamestringbroadcast-events.tsFilename for the combined index file
broadcast_events.index_templatestringlaravel-ts-publish::broadcast-events-indexBlade template for the index file
broadcast_events.templatestringlaravel-ts-publish::broadcast-eventBlade template for each per-event interface file
broadcast_events.output_directorystring''Custom output directory for event files. Empty uses output_directory
broadcast_events.includedarray[]Only publish these event classes (empty = all)
broadcast_events.excludedarray[]Exclude these event classes from publishing
broadcast_events.additional_directoriesarray[]Extra directories to search for event classes
broadcast_events.collector_classstringBroadcastEventsCollectorDiscovers ShouldBroadcast classes
broadcast_events.generator_classstringBroadcastEventGeneratorOrchestrates transforming and writing
broadcast_events.transformer_classstringBroadcastEventTransformerConverts a PHP event class into TypeScript data
broadcast_events.writer_classstringBroadcastEventWriterWrites per-event TypeScript files
broadcast_events.index_writer_classstringBroadcastEventsIndexWriterWrites the combined index file
broadcast_events.echo_augmentation.enabledbooltrueGenerate the Echo module augmentation file
broadcast_events.echo_augmentation.echo_package?stringnullnpm package to augment. When null, the first of these that your package.json lists, checked in this order: @laravel/echo-vue, @laravel/echo-react, @laravel/echo-svelte. With none of them, @laravel/echo
broadcast_events.echo_augmentation.filenamestringecho-broadcast-events.d.tsFilename for the Echo augmentation file
broadcast_events.echo_augmentation.templatestringlaravel-ts-publish::echo-broadcast-eventsBlade template for the Echo augmentation file
broadcast_events.echo_augmentation.output_directorystring''Custom output directory for the Echo augmentation file. Empty uses broadcast_events.output_directory, then output_directory
broadcast_events.echo_augmentation.writer_classstringBroadcastEventsEchoWriterWrites the Echo augmentation file

Inertia (inertia.*) ​

Config KeyTypeDefaultDescription
inertia.enabledbooltrueEnable or disable Inertia shared-data and page-prop analysis
inertia.inertia_middleware_path?stringnullDirectory to search for the HandleInertiaRequests middleware (defaults to app_path())
inertia.augmentation_filenamestringinertia-config.d.tsFilename for the generated module augmentation file
inertia.output_directorystring''Custom output directory. Empty uses routes.output_directory, then the global output_directory
inertia.component_casingstring'camel'Casing style for derived page-prop export names, used by the per-route page props. See Inertia Integration
inertia.ui_table_package?stringnullnpm package used for InertiaUI Table integration, used by the per-route page props

Vite Env (vite_env.*) ​

Config KeyTypeDefaultDescription
vite_env.enabledbooltrueEnable Vite environment type generation
vite_env.filenamestringvite-env.d.tsFilename for the Vite env declaration file
vite_env.output_directorystring''Custom output directory for the Vite env file. Empty uses output_directory
vite_env.source_file?stringnullSource .env file (defaults to .env, falls back to .env.example)

Cache Generation (cache.*) ​

Config KeyTypeDefaultDescription
cache.enabledbooltrueSkip re-generating unchanged classes after the first run
cache.store?stringnullnull = file cache under directory; or a Laravel cache store name
cache.directorystringstorage/framework/cache/ts-publishDirectory for the file-based cache
cache.key?stringnullHMAC signing key for the cache (file and store); defaults to app.key

The published config reads cache.enabled, cache.store, and cache.key from the TS_PUBLISH_CACHE_ENABLED, TS_PUBLISH_CACHE_STORE, and TS_PUBLISH_CACHE_KEY environment variables. See Cache Generation for what triggers a rebuild, the storage options, and the --fresh flag.

Released under the MIT License.