Download the PHP package stubbedev/laravel-stoli without Composer

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

Laravel Stoli

stubbedev/laravel-stoli is a Laravel package that exports your application's named routes to TypeScript, enabling you to use route names instead of hardcoded URLs in your frontend code. It builds on top of spatie/laravel-data and spatie/laravel-typescript-transformer — both are required dependencies — and generates fully typed TypeScript definitions including parameter types inferred from FormRequest validation rules, URI constraint types, and response types derived from Data classes and the transformer's generated output.

Requirements

Installation

Publish and configure spatie/laravel-typescript-transformer first — Stoli uses its output directory as the destination for all generated files:

Then publish the Stoli configuration:

Generate routes and types:

stoli:generate writes the following into the typescript-transformer output directory:

Usage

Basic

Typed parameters

The generated route file exports ApiRouteParams and ApiRouteName. URI parameters ({id}, {slug?}) are always included. When a controller method accepts a FormRequest, its validation rules are also included as typed fields.

URI constraint types

When routes declare ->where() constraints, the parameter type is narrowed accordingly:

Without a constraint the type is string | number. Optional parameters ({param?}) become param?: type.

FormRequest parameter types

Validation rules are reflected directly into TypeScript:

Laravel rule TypeScript type
string, email, url, uuid, … string
integer, numeric, decimal:… number
boolean, accepted, declined boolean
array Record<string, unknown>
list, distinct unknown[]
file, image File
in:a,b,c / Rule::enum(MyEnum::class) 'a' \| 'b' \| 'c'
nullable modifier adds \| null
Nested dot-notation (address.city) inline object type
Wildcard arrays (tags.*) string[] / { … }[]

Typed responses

Each generated module also exports ApiRouteResponse, a per-route map of response shapes. A route is included in the interface when its controller method has a return type annotation that is a Spatie\LaravelData\Data subclass and that class has been transformed by php artisan typescript:transform.

The generated interface looks like:

Routes without a resolvable Data return type are absent from the interface. The axios router (see below) falls back to Record<string, unknown> for those routes.

Spatie Laravel Data

Controllers returning Spatie\LaravelData\Data objects are detected automatically. The TypeScript shape is derived from the class's public typed properties:

Generates:

Supported property types:

PHP type TypeScript type
int, float number
string string
bool boolean
?type / type\|null type \| null
Nested Data subclass inline object type
DataCollection + #[DataCollectionOf(T::class)] T[]
array + #[DataCollectionOf(T::class)] T[]
DateTimeInterface string
Collection unknown[]

Spatie Laravel TypeScript Transformer

When php artisan typescript:transform has already been run, Stoli uses the generated type names directly instead of re-deriving inline shapes:

The import path is computed relative to the module's output directory. Always run typescript:transform before stoli:generate:

Axios router (optional)

Enable in config/stoli.php:

The generated router (api.router.ts) wraps axios with full type inference for both params and responses:

Requires axios: npm install axios

Route service methods

Method Description
generateFullURL(name, params?) Full URL; leftover params are appended as query string
createURLWithoutQuery(name, params?) URL with only URI params substituted; no query string
has(name) Returns true if the route exists

Configuration

Publish and edit config/stoli.php to customise.

All generated files are written to the output_path configured in config/typescript-transformer.php. Per-module path can override this for individual modules.

Module options

Option Default Description
match * URL prefix to filter routes. * matches all, /api/store matches only routes under that path
name Output filename (without extension)
rootUrl APP_URL Base URL for absolute URLs
absolute true Generate absolute (https://…) or relative (/…) URLs
prefix null Prefix prepended to every generated URL
path transformer output dir Output directory for this module's .ts file
stripPrefix null Route name prefix to strip (e.g. store. turns store.products.list into products.list)

Multiple modules

Split routes into separate typed files per API consumer:

This generates store.ts and admin.ts, each with their own StoreRouteParams / AdminRouteParams / StoreRouteResponse / AdminRouteResponse interfaces.

License

MIT. See license.


All versions of laravel-stoli with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
laravel/framework Version ^v11.15|^12.0|^13.0
spatie/laravel-data Version ^3|^4
spatie/laravel-typescript-transformer Version ^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 stubbedev/laravel-stoli contains the following files

Loading the files please wait ...