switch to php composer

This commit is contained in:
2026-07-22 12:55:08 +02:00
parent 151bc70775
commit 01b22f9c2d
16 changed files with 128 additions and 25 deletions
+47
View File
@@ -0,0 +1,47 @@
param(
[Parameter(Mandatory)][string]$Command,
[string[]]$Arguments = @()
)
$ErrorActionPreference = 'Stop'
$root = (Resolve-Path (Join-Path (Split-Path -Parent $MyInvocation.MyCommand.Path) '..')).Path
$useDockerComposer = $false
$dockerRoot = $null
if (-not (Get-Command composer -ErrorAction SilentlyContinue)) {
Write-Host "Composer non trovato localmente. Verifico se Docker è disponibile..."
if (-not (Get-Command docker -ErrorAction SilentlyContinue)) {
throw "Composer non trovato e Docker mancante! Installa Composer o Docker prima di continuare."
}
$dockerRoot = $root -replace '\\', '/'
if ($dockerRoot -match '^([A-Za-z]):') {
$dockerRoot = "/$($Matches[1].ToLower())$($dockerRoot.Substring(2))"
}
Write-Host "Docker trovato. Verifico Composer tramite container..."
docker run --rm -v "$($dockerRoot):/app" -w /app composer:2 composer --version 2>&1
if ($LASTEXITCODE -ne 0) {
throw "Docker presente, ma Composer non riesce ad avviarsi tramite container. Installa Composer localmente o verifica Docker."
}
$useDockerComposer = $true
}
Push-Location $root
try {
if ($useDockerComposer) {
docker run --rm -v "$($dockerRoot):/app" -w /app composer:2 composer $Command @Arguments
}
else {
composer $Command @Arguments
}
if ($LASTEXITCODE -ne 0) {
throw "Composer ha restituito il codice di uscita $LASTEXITCODE."
}
}
finally {
Pop-Location
}