spatie/typescript-transformer
Automatically generate TypeScript definitions from your PHP/Laravel code. spatie/typescript-transformer scans classes and types, then outputs .d.ts files so your frontend stays in sync with backend models, DTOs and enums with minimal manual typing.
The package provides some loggers that can be used to log messages during the transformation process, out of the box the package provides the following loggers:
ArrayLogger: Logs messages to an array which can be retrieved laterSymfonyConsoleLogger: Logs messages to the Symfony Console outputNullLogger: A logger that logs nothingRayLogger: Logs messages to Ray (https://spatie.be/docs/ray)MultiLogger: A logger that logs messages to multiple loggersThe Laravel package provides an additional logger:
LaravelConsoleLogger: Logs messages to the Laravel console outputA logger can be configured when constructing the Runner.
Implementing your own logger is possible by implementing the Logger interface:
namespace Spatie\TypeScriptTransformer\Support\Loggers;
interface Logger
{
public function debug(mixed $item, ?string $title = null): void;
public function info(mixed $item, ?string $title = null): void;
public function warning(mixed $item, ?string $title = null): void;
public function error(mixed $item, ?string $title = null): void;
}
How can I help you explore Laravel packages today?