64 lines
1.9 KiB
PowerShell
64 lines
1.9 KiB
PowerShell
$ErrorActionPreference = "Stop"
|
|
|
|
function Resolve-PhpCommand {
|
|
$phpCommand = Get-Command php -ErrorAction SilentlyContinue
|
|
if ($phpCommand) {
|
|
return "php"
|
|
}
|
|
|
|
$candidates = @(
|
|
"D:\\xampp\\php\\php.exe",
|
|
"C:\\xampp\\php\\php.exe",
|
|
"C:\\wamp64\\bin\\php\\php8.3.0\\php.exe",
|
|
"C:\\wamp64\\bin\\php\\php8.2.0\\php.exe",
|
|
"C:\\wamp64\\bin\\php\\php8.1.0\\php.exe"
|
|
)
|
|
|
|
foreach ($candidate in $candidates) {
|
|
if (Test-Path $candidate) {
|
|
return $candidate
|
|
}
|
|
}
|
|
|
|
return $null
|
|
}
|
|
|
|
if (-not (Test-Path "./mediawiki/composer.json")) {
|
|
Write-Error "Missing ./mediawiki/composer.json. Run 'npm run mw:init' first."
|
|
}
|
|
|
|
$php = Resolve-PhpCommand
|
|
if (-not $php) {
|
|
Write-Error "PHP executable not found. Install XAMPP/WampServer or add php.exe to PATH."
|
|
}
|
|
|
|
if (-not (Test-Path "./composer.phar")) {
|
|
Write-Host "Downloading Composer locally (composer.phar)..."
|
|
& $php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
|
|
if (-not (Test-Path "./composer-setup.php")) {
|
|
Write-Error "Could not download Composer installer."
|
|
}
|
|
& $php .\composer-setup.php --filename=composer.phar
|
|
Remove-Item .\composer-setup.php -ErrorAction SilentlyContinue
|
|
}
|
|
|
|
Write-Host "Checking required PHP extensions..."
|
|
$loadedExtensions = (& $php -m) | ForEach-Object { $_.Trim().ToLower() }
|
|
$requiredExtensions = @("intl")
|
|
$missing = @()
|
|
|
|
foreach ($ext in $requiredExtensions) {
|
|
if ($loadedExtensions -notcontains $ext) {
|
|
$missing += $ext
|
|
}
|
|
}
|
|
|
|
if ($missing.Count -gt 0) {
|
|
Write-Error "Missing PHP extension(s): $($missing -join ', '). Enable them in php.ini and restart dev server."
|
|
}
|
|
|
|
Write-Host "Installing MediaWiki Composer dependencies..."
|
|
& $php .\composer.phar --working-dir=mediawiki install --no-dev --prefer-dist --optimize-autoloader
|
|
|
|
Write-Host "MediaWiki dependencies are installed."
|