Download the PHP package evanschleret/laravel-typebridge without Composer
On this page you can find all versions of the php package evanschleret/laravel-typebridge. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download evanschleret/laravel-typebridge
More information about evanschleret/laravel-typebridge
Files in evanschleret/laravel-typebridge
Package laravel-typebridge
Short Description Generate deterministic TypeScript resources from Laravel resource attributes
License MIT
Informations about the package laravel-typebridge
Laravel TypeBridge
Deterministic TypeScript generation from Laravel resources.
Why this package
This package helps you keep backend resources and frontend types aligned, with deterministic output and predictable imports.
Requirements
- PHP
>=8.2 - Laravel
12.xor13.x - Note: Laravel
13.xrequires PHP>= 8.3(Laravel framework requirement)
Installation
Publish the config:
Generated file:
config/typebridge.php
Basic usage
Generate files:
Use another output directory:
Preview only (no write):
Generate and remove stale .ts files:
Generate only selected resources:
Generate everything except selected resources:
Check generated files in CI:
Attribute example
Use TypeBridgeResource on Laravel resources (JsonResource or ResourceCollection):
Optional attribute fields:
types: local TypeScript aliases/enums declared in the same generated filefileName: per-resource output filename overrideappend: per-resource lines appended at the end of the generated filealiasBaseandaliasPlural: alias placeholders used bygeneration.append_templates
@relation(name) is strict:
- the resource model must be resolvable
- the relation method must exist
- the relation method must return an Eloquent relation
If the relation exists but no generated TypeScript type is available for the related model, the field falls back to any or any[].
@enum(Fully\\Qualified\\EnumClass) generates a TypeScript literal union from PHP enum cases.
Configuration
Published default config
This is the default config generated by vendor:publish:
Advanced config example (API wrappers + aliases)
This is an example, not the default:
Additional outputs
output.additional_paths are generated on every typebridge:generate call when --output-path is not used.
If you use --output-path, additional paths are skipped unless you pass --with-additional-paths.
With RoleItem, this can generate:
Naming placeholders
For files.naming_pattern:
{name}{pascal}{camel}{snake}{kebab}
Example:
Template placeholders
Inside append_templates.*.lines:
{name}: resource name{base}: alias base (aliasBaseor suffix stripping){basePlural}: alias plural (aliasPluralor pluralized base){pascal}{camel}{snake}{kebab}
Override rules
fileNameon the attribute overridesfiles.naming_patternfor one resource--output-pathoverridesoutput.base_path
Roadmap
- [x] Add
typebridge:checkfor CI (no write, non-zero exit code when generated files are out of date) - [x] Add
--onlyand--exceptto generate a subset of resources - [x] Add
--cleanto remove stale generated files - [x] Improve
@relation(...)diagnostics with more actionable error messages - [x] Add enum helpers (for example
@enum(...)support) - [ ] Add configurable scalar mapping presets (
datetime,uuid,decimal, etc.) - [ ] Add configurable import/path strategy options
- [ ] Add a first-class paginator wrapper preset
- [ ] Add pre/post render hooks for advanced customization
- [ ] Add incremental generation mode for large codebases
- [ ] Add stubs/scaffolding helpers for
#[TypeBridgeResource] - [ ] Add optional targets beyond interfaces (for example Zod schema generation)
Other packages
If you want to explore more of my Laravel packages:
Open source
- Contributing guide: CONTRIBUTING.md
- Security policy: SECURITY.md
- Code of conduct: CODE_OF_CONDUCT.md
- License: LICENSE
All versions of laravel-typebridge with dependencies
illuminate/console Version ^12.0 || ^13.0
illuminate/database Version ^12.0 || ^13.0
illuminate/filesystem Version ^12.0 || ^13.0
illuminate/http Version ^12.0 || ^13.0
illuminate/support Version ^12.0 || ^13.0