Compare With Laravel
Introduction
DotBlaze follows Laravel's structure, so its concepts, facades, and most method names carry over. The table below shows the same task in both frameworks. Features marked Not Yet are not built in DotBlaze. The roadmap lists what may come next.
Feature Comparison
| Feature | Laravel | DotBlaze |
|---|---|---|
| Console Commands | php artisan migrate | dotblaze migrate |
| Authentication | Auth::login($user) | await Auth.Login(user) |
| Authorization | Gate::authorize('update', $post) | await Gate.Authorize("update", post) |
| Cache | Cache::put('key', 'value', 60) | await Cache.Put("key", "value", TimeSpan.FromMinutes(1)) |
| Collections | collect([1, 2, 3])->map(...) | Collect(new[] { 1, 2, 3 }).Map(...) |
| Config | config('app.name') | Config.Get<string>("app.name") |
| Cookies | Cookie::queue('theme', 'dark') | Cookie.Queue("theme", "dark") |
| Context | Context::add('request_id', $id) | Context.Add("request_id", id) |
| Dates | Date::now() | Date.Now, Date.Freeze(instant) |
| Error Handling | ->withExceptions(fn ($e) => $e->report(...)), abort(404) | Exceptions.Report<T>(...), Abort(404) |
| Encryption | Crypt::encryptString('text'), APP_KEY, php artisan key:generate | Crypt.Encrypt("text"), APP_KEY, dotblaze key:generate |
| CSRF Protection | @csrf, 419 Page Expired | @Csrf(), 419 Page Expired |
| Database | DB::table('users')->get() | await DB.Table("users").Get() |
| Email Verification | MustVerifyEmail | IMustVerifyEmail |
| Events | OrderShipped::dispatch($order) | await Event.Dispatch(new OrderShipped(order)) |
| Framework Events | DB::listen(fn ($query) => ...) | Instrumentation.Listen<QueryExecuted>(q => ...) |
| File Storage | Storage::put('file.txt', 'content') | await Storage.Put("file.txt", "content") |
| Hashing | Hash::make('password') | Hash.Make("password") |
| Helpers | Str::slug('Hello World') | Str.Slug("Hello World") |
| HTTP Client | Http::get('https://example.com') | await Http.Get("https://example.com") |
| Live Components (Livewire) | <livewire:counter /> | <live:counter /> |
| Persistent Middleware | Livewire::addPersistentMiddleware([...]) | Automatic for every route middleware and .Can check |
| Logging | Log::info('message') | Log.Info("message") |
Mail::to($user)->send(new OrderShipped($order)) | await Mail.To(user).Send(new OrderShipped { Order = order }) | |
| Middleware | Route::middleware('auth') | .Middleware("auth") |
| Middleware Parameters | ->middleware('role:admin,editor') | .Middleware("role:admin,editor") |
| Middleware Groups | web / api groups | web (default) / api groups, Route.MiddlewareGroup(...) |
| Excluding Middleware | ->withoutMiddleware('csrf') | .WithoutMiddleware("csrf") |
| Throttling | ->middleware('throttle:60,1'), RateLimiter::for('api', ...) | .Middleware("throttle:60,1"), RateLimiter.For("api", ...) |
| Trim Strings | TrimStrings | trim-strings (in web and api) |
| Migrations | Schema::create('posts', ...) | Schema.Create("posts", t => ...) |
| Mocking | Mail::fake() | Mail.Fake() |
| Models (Eloquent) | User::find(1) | await User.Find(1) |
| Find or Create | User::firstOrCreate([...], [...]) | await User.FirstOrCreate(new { ... }, new { ... }) |
| Global Model Scopes | Post::addGlobalScope(...) | Post.AddGlobalScope("published", p => p.Published) |
| Relationship Aggregates | Author::withCount('books')->get() | await Author.Query().WithCount(a => a.Books).Get() |
| Pivot Operations | $book->tags()->sync($ids) | await book.ManyToMany(b => b.Tags).Sync(ids) |
| Polymorphic Relations | Relation::morphMap([...]), $comment->commentable | Model.MorphMap<Post>("post"), await Model.MorphTo(type, id) |
| Quiet Saves | $post->saveQuietly() | await post.SaveQuietly() |
| Per-Instance JSON | $user->makeHidden('email') | user.MakeHidden("Email") |
| Notifications | $user->notify(new InvoicePaid($invoice)) | await user.Notify(new InvoicePaid { Invoice = invoice }) |
| Pagination | Post::paginate(10) | await Post.Query().Paginate(10) |
| Password Reset | Password::sendResetLink($credentials) | await Password.SendResetLink(...) |
| Queues | SendEmail::dispatch() | await new SendEmail { ... }.Dispatch() |
| Rate Limiting | RateLimiter::tooManyAttempts($key, 5) | await RateLimiter.TooManyAttempts(key, 5) |
| Redis | Redis::get('key') | await Redis.Connection().StringGetAsync("key") |
| Responses | return back()->with('status', '...') | return Back().With("status", "...") |
| Routing | Route::get('/', [HomeController::class, 'index']) | Route.Get<HomeController>("/", c => c.Index) |
| Seeding | $this->call(UserSeeder::class) | await Call<UserSeeder>() |
| Testing | $this->get('/posts')->assertOk() | (await client.Get("/posts")).AssertOk() |
| URL Generation | URL::signedRoute('unsubscribe', ...) | URL.SignedRoute("unsubscribe", ...) |
| Validation | FormRequest | FormRequest<TSelf> |
| Standalone Validation | Validator::make($input, $rules) | await Validator.Validate(input, rules => ...) |
| Views | view('welcome') | View("welcome") (Blade or Razor) |
| Blade Templates | @foreach ($posts as $post) {{ $post->title }} @endforeach | @foreach (var post in Model.Posts) {{ post.Title }} @endforeach |
| Rendering Blade Strings | Blade::render($template, ['user' => $user]) | BladeTemplate.Compile(template).Render(new { user }) (sandboxed) |
| API Tokens (Sanctum) | $user->createToken('api') | await user.CreateToken("api") |
| Broadcasting | broadcast(new OrderShipped($order))->toOthers() | await Broadcast.Send(new OrderShipped(order)).ToOthers() |
| Private & Presence Channels | Broadcast::channel('orders.{id}', ...) | Broadcast.Channel("orders.{id}", ...) |
| Components (Blade) | <x-alert type="error" /> | <x-alert type="error" /> |
| Cursor Pagination | Post::cursorPaginate(15) | await Post.Query().CursorPaginate(p => p.Id) |
| Database Cache Store | 'driver' => 'database' | driver = "database" |
| Job Chaining & Batching | Bus::chain([...])->dispatch() | await Bus.Chain(...).Dispatch() |
| Job Middleware | new WithoutOverlapping($id) | new WithoutOverlapping(id) |
| Unique Jobs | ShouldBeUnique | IShouldBeUnique |
| Localization | __('messages.welcome') | __("messages.welcome") |
| Maintenance Mode | php artisan down --secret=... | dotblaze down --secret=... |
| Model Factories | User::factory()->count(10)->create() | await User.Factory().Count(10).CreateMany() |
| Observers | User::observe(UserObserver::class) | User.Observe<UserObserver>() or [ObservedBy(...)] |
| Package Development | $this->loadViewsFrom($path, 'courier') | [assembly: DotBlazePackage], View("courier::welcome") |
| Password Confirmation | ->middleware('password.confirm') | .Middleware("password.confirm") |
| Processes | Process::run('ls -la') | await Process.Run("ls -la") |
| Pipelines | Pipeline::send($value)->through([...])->thenReturn() | await Pipeline.Send(value).Through(...).ThenReturn() |
| Calling Commands | Artisan::call('route:list') | await Artisan.Call("route:list") |
| Images | Image | Image.Read(bytes).Resize(1200, 800) (DotBlaze.Image) |
| AI SDK | agent()->prompt('...') | await Ai.Agent().Prompt("...") (DotBlaze.AI; see the provider matrix) |
| Vite | @vite('resources/js/app.js') | @Vite.Assets("resources/js/app.js") |
| Session | session(['key' => 'value']) | await Session.Put("key", "value") |
| Social Login (Socialite) | Socialite::driver('github')->redirect() | await Socialite.Driver("github").Redirect() |
| Task Scheduling | Schedule::command('emails:send')->daily() | Schedule.Command("emails:send").Daily() |
| Testing Helpers | $this->actingAs($user)->post(...)->assertRedirect() | (await client.ActingAs(user).Post(...)).AssertRedirect() |
| Tinker | php artisan tinker | dotblaze tinker |
| Two-Factor Authentication (Fortify) | TwoFactorAuthenticatable | ITwoFactorAuthenticatable, TwoFactor.Enable(user) |
| ULIDs | Str::ulid() | Str.Ulid() |
| Horizon | php artisan horizon, /horizon | dotblaze queue:manager, /horizon (DotBlaze.Horizon) |
| Telescope | /telescope, Telescope::filter(...) | /telescope, Telescope.Filter(...) (DotBlaze.Telescope) |
| Pulse | php artisan pulse:check, /pulse | dotblaze pulse:check, /pulse (DotBlaze.Pulse) |
| Scout (full-text search) | Post::search('term') | Not Yet |
AI SDK Comparison
DotBlaze.AI follows the Laravel AI SDK's concepts with C# types and asynchronous APIs. Provider/model support varies: this is an API correspondence, not a claim that every provider supports every operation. See the provider matrix for details.
| Feature | Laravel AI SDK | DotBlaze |
|---|---|---|
| Named agents | SalesCoach::make()->prompt('...') | await SalesCoach.Make().Prompt("...") |
| Agent configuration | Provider, model, temperature, token/step limits, timeout, cheapest/smartest attributes | [Provider], [Model], [Temperature], [MaxTokens], [MaxSteps], [Timeout], [UseCheapestModel], [UseSmartestModel] |
| Conversations | Remember and continue conversations | ForUser(...), Continue(...), owner-scoped listing, pagination, and deletion |
| Structured output | Agent output schemas | Structured<T>(), JSON Schema and recursive data-annotation validation |
| Classification | Boolean, choice, and score questions | Classification.Of(...).Boolean(...), .Choice(...), .Score(...), plus label classification |
| Tools and MCP clients | Agent tools and external MCP tools | Tools(), AIFunctionFactory.Create(...), MCP AIFunction integration |
| Provider-hosted tools | Web search, web fetch, file search | HostedWebSearchTool, HostedWebFetchTool, HostedFileSearchTool; also hosted code execution where supported |
| Similarity search | SimilaritySearch::usingModel(...) | SimilaritySearch.UsingModel<T>(...), .UsingTable(...), or a custom search function |
| Database vector search | whereVectorSimilarTo(...) with pgvector | WhereVectorSimilarTo(...), vector distance selection/ordering, pgvector columns/indexes |
| Middleware | Agent prompt middleware | Middleware() with DelegatingChatClient wrappers |
| Streaming | Streamed responses and Vercel data protocol | Stream(...), UsingVercelDataProtocol(), UsingAgentUserInteractionProtocol() |
| Images | Image::of(...)->generate() | Image.Of(...).Generate(), including reference-image edits |
| Audio and transcription | Speech generation and transcription | Audio.Of(...), Transcription.FromStorage(...), speaker diarization |
| Embeddings and reranking | Embeddings, caching, reranking | Embeddings.For(...), .Cache(...), multimodal inputs, Reranking.Of(...) |
| Files and vector stores | Uploaded documents and hosted retrieval stores | Files.Document.FromPath(...).Put(), Stores.Create(...), metadata-filtered search |
| Queue and broadcast | Queue/broadcast agent responses | Queue(...), BroadcastOnQueue(...), QueueStructured<T>(...), QueueClassify(...) |
| Completion callbacks | then(...) / catch(...) | Stream callbacks; serializable queue handler classes with Then<THandler>() / Catch<THandler>() |
| Lifecycle events | Prompt, tool, and generation events | Event.Listen<AgentPrompted>(...), tool events, generation events |
| Fakes | Agent and generation fakes | SalesCoach.Fake(...), per-feature fakes, prompt/generation assertions |
| Generators | make:agent, make:tool | dotblaze make:agent, dotblaze make:tool |
Additional capabilities documented in DotBlaze include estimated context-token budgets with optional summarization, provider-specific reasoning controls, and OpenAI remote history/background polling and stream resumption through Ai.Chat(). These do not imply identical Laravel APIs. Queue callbacks use handler classes rather than serialized closures; classification probabilities are model estimates, not calibrated confidence. The planned MCP server package is separate from the external MCP tools already usable by agents.
Only in DotBlaze
| Feature | Laravel | DotBlaze |
|---|---|---|
| Schema Check | Not built in | dotblaze db:check compares models with the database |
| Static Typing | Not built in | Routes, controllers, and models are checked by the C# compiler |
Complete Translation Example
For the complete model, request, policy, route, and view behind a controller action, follow the blog walkthrough. This is its update operation:
// Method in Blog.Controllers.PostController from the walkthrough.
public async Task<IActionResult> Update(Post post, PostRequest request)
{
await Authorize("update", post);
await post.Update(new { request.Title, request.Body });
return RedirectRoute("posts.show", new { post = post.Id })
.With("status", "Post updated.");
}| Laravel concept | What to implement in this example |
|---|---|
| Route model binding | {post} and Post post must have matching names. |
| Form request | A typed PostRequest : FormRequest<PostRequest> with Rules. |
$fillable | [Fillable] on Title and Body. |
| Policy | PostPolicy : Policy<Post> with Update(User, Post). |
redirect()->route()->with() | RedirectRoute(...).With(...). |
@csrf and @method('PUT') | The same directives in Blade; @Csrf() and @Method("PUT") in Razor. |
Compile-time types replace PHP's dynamic properties; Task methods must be awaited. The walkthrough's test checks both the successful update and a different user's forbidden update, so copying the syntax also preserves the authorization behavior.