Download the PHP package kiwilan/typescriptable-laravel without Composer

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

Typescriptable for Laravel

Banner with printer shop picture in background and Typescriptable Laravel title

php version downloads license codecov tests

laravel npm

PHP package for Laravel to type Eloquent models, routes, Spatie Settings with autogenerated TypeScript.

If you want to use some helpers with Inertia, you can install associated NPM package.

Eldorado Road Both Scene

Because you need PHP and Typescript.

Features

Roadmap

Installation

This version requires PHP 8.2+ and supports Laravel 11.

[!WARNING]

Laravel 11 dropped Doctrine DBAL. For previous Laravel versions, you can use 1.12.03 version.

Version L9 L10 L11
v3+ :x: :x: :white_check_mark:
v1.12.03 :white_check_mark: :white_check_mark: :x:

You can install the package via composer:

With Laravel v11+ and PHP 8.2

With Laravel v9-10 and PHP 8.1

About TypeScript

If you want to use .d.ts files, you need to use TypeScript in your Laravel project, you have to create a tsconfig.json file and add .d.ts paths in include:

[!NOTE]

If you change paths into config or with options, adapt paths.

Complete `tsconfig.json` Here is a complete `tsconfig.json` file example (you can adapt paths):

About NPM package @kiwilan/typescriptable-laravel

NPM package is fully optional, you can use only PHP package. It's built for Vite with laravel-vite-plugin and Inertia (only for Vue 3). It's SSR compatible.

This package add some helpers to use Laravel routes fully typed with TypeScript into Vue components and some composables to use with Vue. The best setup to install this package is to use Jetstream, a Laravel starter kit and tightenco/ziggy is required.

Read full documentation here: @kiwilan/typescriptable-laravel.

Configuration

You can publish the config file

A config example is available here: config/typescriptable.php.

[!IMPORTANT]

You can configure engine.eloquent with artisan or parser to change parser engine. By default, it uses artisan command with model:show command. artisan is default engine because it's more reliable and faster than parser engine. With MongoDB, the engine doesn't matter because MongoDB database can't be parsed like relational databases.

Usage

With options:

Eloquent models

Generate resources/js/types-eloquent.d.ts file with all models types.

Options can be set into config/typescriptable.php file.

Spatie Settings

If you use spatie/laravel-settings, you can generate resources/js/types-settings.d.ts file with all settings types.

Options can be set into config/typescriptable.php file.

Routes

Generate resources/js/types-routes.d.ts file with all routes types and resources/js/routes.ts for routes references.

Options can be set into config/typescriptable.php file.

Eloquent listing

Show all Eloquent models with eloquent:list command.

Models are parsed from config/typescriptable.php with eloquent.directory variable.

Advanced

MongoDB

kiwilan/typescriptable-laravel supports MongoDB with mongodb/laravel-mongodb. Due to the MongoDB structure, Typescript conversion aren't the same as SQL databases, precision is lower. If you want to improve it, you can add an issue.

Database isn't parsed like with relational databases. The package will parse key, fillable and hidden to get all fields. If some fields are missing, you can override them manually. All relations and accessors are supported.

Database prefix

You can use prefix variable into config/database.php file.

Override models

kiwilan/typescriptable-laravel will cover many cases, but if you want to override some models, you can just create a type like resources/js/types/index.ts and extends Model type.

And you can import custom type in your code when you need to use advanced type.

Print PHP classes

If you want to print PHP classes, you can use --php-path option with php artisan typescriptable:eloquent command.

These classes will be generated from Eloquent models as real PHP classes.

Examples

Check examples documentation.

Testing

Create a .env file with your database configuration

And you can run tests

[!NOTE]

You can check this gist to have a Docker database configuration.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of typescriptable-laravel with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/contracts Version ^11.0
illuminate/database Version ^11.0
illuminate/support Version ^11.0
spatie/laravel-package-tools Version ^1.16.3
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 kiwilan/typescriptable-laravel contains the following files

Loading the files please wait ....