AgentSkillsCN

php-to-dotnet-mapping

PHP 至 .NET 10 的代码映射参考。适用于将 PHP 代码模式转换为 .NET 等效代码,包括框架映射、身份验证、模板(Blade 至 Razor)、包管理(Composer 至 NuGet),以及验证规则。

SKILL.md
--- frontmatter
name: php-to-dotnet-mapping
description: PHP to .NET 10 code mapping reference. Use when converting PHP code patterns to .NET equivalents including framework mapping, authentication, templates (Blade to Razor), packages (Composer to NuGet), and validation rules.

PHP to .NET 10 Mapping Reference

Use this skill when migrating PHP code to .NET 10. It provides direct mappings for common patterns.

Framework Mapping

PHP Framework.NET 10 Equivalent
LaravelASP.NET Core MVC
SymfonyASP.NET Core MVC
CodeIgniterASP.NET Core Minimal APIs
SlimASP.NET Core Minimal APIs
LumenASP.NET Core Minimal APIs

Architecture Pattern Mapping

PHP Pattern.NET 10 Equivalent
MVC (Laravel/Symfony)ASP.NET Core MVC
API-onlyASP.NET Core Web API / Minimal APIs
Blade/Twig templatesRazor Views
LiveWireBlazor Server

Data Access Mapping

PHP.NET 10
Eloquent ORMEntity Framework Core
Doctrine ORMEntity Framework Core
PDOADO.NET / Dapper
Query BuilderLINQ
MigrationsEF Core Migrations

Authentication Mapping

PHP.NET 10
Laravel AuthASP.NET Core Identity
Laravel SanctumJWT Bearer Authentication
Laravel PassportIdentityServer / Duende
PHP SessionsASP.NET Core Session
tymon/jwt-authMicrosoft.AspNetCore.Authentication.JwtBearer
SocialiteOAuth2 / Microsoft.Identity.Web

Dependency Injection

PHP.NET 10
Laravel ContainerBuilt-in DI Container
Symfony DIBuilt-in DI Container
Service ProvidersIServiceCollection extensions
FacadesInjected services

Template Syntax Mapping (Blade → Razor)

Blade (PHP)Razor (.NET)
{{ $var }}@Model.Var or @var
{!! $html !!}@Html.Raw(html)
@if($cond)@if (cond)
@foreach($items as $item)@foreach (var item in items)
@extends('layout')@{ Layout = "_Layout"; }
@section('content')@section Content { }
@yield('content')@RenderSection("Content")
@include('partial')<partial name="_Partial" />
@csrf@Html.AntiForgeryToken()
@auth@if (User.Identity?.IsAuthenticated == true)
{{ route('name') }}@Url.Action("Action", "Controller")
@componentView Component

Package Mapping (Composer → NuGet)

Composer PackageNuGet Package
guzzlehttp/guzzleHttpClient (built-in)
stripe/stripe-phpStripe.net
intervention/imageImageSharp
tymon/jwt-authMicrosoft.AspNetCore.Authentication.JwtBearer
predis/predisStackExchange.Redis
aws/aws-sdk-phpAWSSDK.*
league/flysystemAzure.Storage.Blobs
phpmailer/phpmailerAzure.Communication.Email / SendGrid
monolog/monologSerilog / ILogger

Configuration Mapping

PHP.NET 10
.env filesappsettings.json + Environment Variables
config/*.phpIOptions<T> pattern
env('KEY')IConfiguration["Key"]

Background Jobs Mapping

PHP.NET 10
Laravel QueuesAzure Service Bus + BackgroundService
Symfony MessengerAzure Service Bus + BackgroundService
Laravel SchedulerHosted Services + Cron expressions
Artisan commands.NET CLI tools

Validation Mapping

Laravel Validation.NET 10
required[Required]
email[EmailAddress]
max:100[MaxLength(100)]
min:1[MinLength(1)] or [Range(1, ...)]
unique:tableCustom validator / EF unique index
confirmed[Compare("PropertyName")]
Form RequestsFluentValidation

Code Examples

See the examples directory for sample conversions: