Download the PHP package gaiatools/laravel-type-bridge without Composer

On this page you can find all versions of the php package gaiatools/laravel-type-bridge. 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 laravel-type-bridge

Gaia Tools Laravel Type Bridge

A Laravel package for generating TypeScript/JavaScript enums and frontend translation files from your Laravel app.

Release Quality Gate License Downloads Coverage

Features

Requirements

Installation

Install the package via Composer:

Publish the configuration file:

Smart config publishing

Or Laravel config publishing

Configuration

See config/type-bridge.php for all configuration options and inline documentation.

Supported translation engines

The translator utilities generated by this package can work with multiple i18n libraries through a tiny "engine" interface (an object exposing t(key: string): string). Out of the box we support:

Tip: In config/type-bridge.php you can set i18n_library to control how translation keys are generated/organized for your target library. The default i18next also covers react-i18next.

Usage

Basic Enum Generation

Create a backed enum in your Laravel application:

Generate the frontend enum (TypeScript by default):

This will create a TypeScript file at resources/js/enums/generated/Status.ts:

To generate JavaScript instead of TypeScript:

Check mode (CI drift detection)

Validate that your previously generated frontend enum files are still in sync with the current PHP enums without writing any files. This is ideal for CI to detect drift.

Run:

Behavior:

Notes:

Examples

In sync:

Differences found (new case added to the PHP enum):

Value change:

Possible rename (unmatched removal and addition):

Output (resources/js/enums/generated/Status.js):

Dirty mode (generate only new/changed enums)

Generate only enums that are missing or out of sync with the frontend output, using the same drift criteria as --check. This is useful for incremental builds or large projects.

Run:

Behavior:

Opt-in Enum Generation

Use the #[GenerateEnum] attribute to explicitly mark enums for generation:

Enum Groups (derived exports)

Enum groups let you export curated subsets or mappings alongside the base enum. Groups are defined by public static methods and are only included when you opt-in via #[GenerateEnum(includeMethods: [...])].

Rules:

Example:

Generated output (TypeScript):

Available Commands

Generate Everything (enums + translations + translators)

Generate Enums

Generate Translations

Translation output examples (for locale en):

Publish Translator Utilities (frontend helpers)

These reusable helpers are required by the generated enum translators. Run once to publish them into your frontend source tree.

Defaults (can be changed in config/type-bridge.php → enum_translators.*):

The file extensions follow your type-bridge.output_format (ts by default).

Generate Enum Translators

Generate per-enum translator composables/functions that map enum values to translated labels using your configured i18n library.

By default files are written to:

Dry-run output columns:

Only enums that are both in the FE generation set and have translations are eligible for generation.

Global translation engine setup (app.ts/js)

The generated translators call a global engine. You must configure it once during your app bootstrapping by calling configureTranslationEngine.

TypeScript (app.ts / main.ts / app.tsx)

JavaScript (app.js / main.js)

Once configured, any generated translator like useStatusTranslator() will use the global engine automatically:

Using the translator utilities

After publishing the utilities and generating translators, you can translate enum values in the frontend.

Global engine configuration (once at app bootstrap) is required. See “Global translation engine setup” above. You can also use the lightweight wrappers from lib/translators:

Manual configuration using i18next works similarly:

Example: translating a generated enum

If you generated the Status enum and have translations under the Status.* namespace, you can build a translator on the fly:

You can also override the engine for a specific translator call:

Notes and configuration

GenerateEnum Attribute Options

The #[GenerateEnum] attribute accepts the following options:

License

MIT


All versions of laravel-type-bridge with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2|^8.3|^8.4|^8.5
illuminate/console Version ^11.0|^12.0|^13.0
illuminate/support Version ^11.0|^12.0|^13.0
mck89/peast Version ^1.17
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 gaiatools/laravel-type-bridge contains the following files

Loading the files please wait ...