Artisan Schematics is the most powerful, extensible, and professional Laravel package for exporting your Eloquent models and PHP enums to TypeScript, Dart, Kotlin, and Swift. It is designed for teams and individuals who want seamless, type-safe, cross-platform development.
composer require saher/artisan-schematics --dev
Publish the config file:
php artisan vendor:publish --provider="Saher\ArtisanSchematics\ArtisanSchematicsServiceProvider"
Edit config/schematics.php to enable/disable languages and set output paths for each target.
Export all models and enums:
php artisan schematics:export
Or specify custom paths:
php artisan schematics:export --paths=app/Models,app/Enums
resource/ts/schemas (default)tests/output/dart (customizable)tests/output/kotlin (customizable)tests/output/swift (customizable)Post.ts, PostStatus.dart, User.kt, Tag.swift, etc.)class User extends Model {
public function posts() { return $this->hasMany(Post::class); }
public function tags() { return $this->belongsToMany(Tag::class); }
public function comments() { return $this->morphMany(Comment::class, 'commentable'); }
public function country() { return $this->hasOneThrough(Country::class, Address::class); }
}
class Post extends Model {
protected $casts = [
'status' => PostStatus::class,
'tags' => 'array',
];
public function author() { return $this->belongsTo(User::class); }
}
class Comment extends Model {
public function post() { return $this->hasMany(Post::class); }
public function tags() { return $this->belongsToMany(Tag::class); }
}
class Tag extends Model {}
class Country extends Model {}
class Address extends Model {}
enum PostStatus: string { case DRAFT = 'draft'; case PUBLISHED = 'published'; }
User.ts, Post.ts, Comment.ts, Tag.ts, Country.ts, Address.ts, PostStatus.tsuser.dart, post.dart, comment.dart, tag.dart, country.dart, address.dart, post_status.dartUser.kt, Post.kt, Comment.kt, Tag.kt, Country.kt, Address.kt, PostStatus.ktUser.swift, Post.swift, Comment.swift, Tag.swift, Country.swift, Address.swift, PostStatus.swiftRun the test suite:
./vendor/bin/pest
Tests assert that all expected files are generated for all languages, including enums and all relationship types.
Add your own generator by implementing GeneratorContract and registering it in config/schematics.php:
'go' => [
'enabled' => true,
'generator' => \App\Generators\GoGenerator::class,
'output_path' => base_path('go/models'),
],
./vendor/bin/pest to your pipeline to ensure your contracts are always up to date.config/schematics.php to change output directories or add new languages.Pull requests, issues, and feature requests are welcome! Help make Artisan Schematics the standard for cross-platform Laravel development.
MIT
How can I help you explore Laravel packages today?