<#
.SYNOPSIS
    Yangquan Wedding - Stop PHP server
.DESCRIPTION
    Kill all PHP processes
#>
#Requires -Version 2

[CmdletBinding()]
param(
    [switch]$Silent
)

$ErrorActionPreference = "Continue"

$APP_NAME = "阳泉婚礼宝典"

if (-not $Silent) {
    Write-Color "============================================" "Cyan"
    Write-Color ("  " + $APP_NAME + " - 停止服务器") "Cyan"
    Write-Color "============================================" "Cyan"
    Write-Color ""
    Write-Color "[信息] 正在停止服务器..." "Cyan"
}

# 终止所有 php.exe 进程（仅限当前用户）
$stoppedCount = 0
Get-Process php -ErrorAction SilentlyContinue | ForEach-Object {
    try {
        Stop-Process -Id $_.Id -Force -ErrorAction SilentlyContinue
        $stoppedCount++
    } catch { }
}

if (-not $Silent) {
    if ($stoppedCount -gt 0) {
        Write-Color ("[信息] 已停止 " + $stoppedCount + " 个 PHP 进程") "Green"
    } else {
        Write-Color "[信息] 未发现运行中的 PHP 服务器" "Gray"
    }
    Write-Color ""
    Start-Sleep -Seconds 2
}
