Entity structure, requiring pre-processing or custom mappings.symfony/bundle, symfony/config, and symfony/dependency-injection. Laravel lacks native bundle support, so integration would require:
%kernel.project_dir% with Laravel’s base_path())..d.ts files from PHP docblocks (e.g., @ORM\Entity, @ORM\Column). Laravel’s Eloquent uses different annotations (@property, @ORM\ via attributes in PHP 8+), which may require custom reflection logic or a pre-processing step.#[ORM\Column(type: 'string')] to TypeScript string types.| Risk Area | Description | Mitigation Strategy |
|---|---|---|
| Symfony-Laravel Gap | Bundle assumes Symfony’s EntityManager and Bundle system. Laravel’s service container and ORM differ. |
Wrap bundle logic in a Laravel service provider; use Laravel’s Model reflection. |
| Annotation Parsing | Doctrine annotations in Laravel (Eloquent) may not match Symfony’s expected format. | Pre-process models with a custom trait or use roave/better-reflection for flexibility. |
| Build Integration | Generated .d.ts files need to be copied to frontend assets. Laravel’s asset pipeline (Vite/Webpack) may require custom config to include dynamically generated files. |
Use Laravel Mix/Vite plugins to watch assets/types and assets/interfaces directories. |
| Performance | Scanning large codebases for entities/enums could impact build times. | Run as a dev-only command (e.g., php artisan ts:generate) or cache results. |
| Maintenance Overhead | Custom integration may diverge from upstream updates. | Fork the bundle or contribute Laravel-specific adaptations to the original repo. |
spatie/laravel-type-script, php-ts) that could reduce integration effort?Illuminate\Support\ServiceProvider to register the generator as an Artisan command.Filesystem and Path helpers to replace Symfony’s %kernel.project_dir%.doctrine/dbal or illuminate/database for reflection. For custom ORMs, implement an adapter interface.resources/assets/types to the frontend’s src/types directory./backend and /frontend), symlink or use npm run dev to trigger generation..d.ts files should be declared in tsconfig.json under include or merged via a composite project.TsGeneratorServiceProvider) that:
Container with Laravel’s Container.get_declared_classes() or roave/better-reflection.TsGenerator class with Laravel-compatible methods.// app/Providers/TsGeneratorServiceProvider.php
public function register()
{
$this->app->singleton(TsGenerator::class, function ($app) {
return new LaravelTsGenerator(
$app['files'],
$app['path'],
config('ts-generator')
);
});
}
php artisan ts:generate) to trigger generation:
// app/Console/Commands/GenerateTsTypes.php
public function handle()
{
$generator = app(TsGenerator::class);
$generator->scanEntities()->generateTypes();
}
// vite.config.ts
export default defineConfig({
build: {
rollupOptions: {
input: {
...,
types: path.resolve(__dirname, 'resources/assets/types/index.ts'),
},
},
},
});
| Component | Laravel Equivalent | Compatibility Notes |
|---|---|---|
| Symfony Bundle | Laravel Service Provider | Requires manual mapping of bundle services to Laravel’s container. |
EntityManager |
Doctrine DBAL or Eloquent Reflection | Use BetterReflection for accurate attribute parsing. |
%kernel.project_dir% |
base_path() |
Replace with Laravel’s path helpers. |
| Symfony Config | Laravel Config (config/ts-generator.php) |
Migrate bundle config to Laravel’s config/ structure. |
| Doctrine Annotations | Eloquent Attributes (PHP 8+) | May need custom logic to handle @property vs. #[Column] differences. |
tsconfig.json to include generated types.composer.json and monitor for breaking changes.How can I help you explore Laravel packages today?