Skip to content

Commit

Permalink
Improve automatic debug launch on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-lerch committed May 15, 2020
1 parent 7435eb8 commit 357f1bc
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions install/devenv.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,16 @@ function EnsureExists ($Path) {
}
}

function GetPhpLocation () {
function GetPhpExecutable ([switch]$Ini) {
if ($Ini -and (Test-Path -Path ".\php.ini" -PathType Leaf)) {
Get-Content -Path ".\php.ini" | Where-Object { $_ -match '^extension_dir.*=.*"(.*)"' } | Out-Null
$executablePath = Join-Path (Split-Path -Path $Matches.1) "php.exe"
Write-Host $executablePath
if (Test-Path -Path $executablePath -PathType Leaf) {
return $executablePath
}
}

$vsConfigPath = "$env:APPDATA\Code\User\settings.json"
if (Test-Path -Path $vsConfigPath -PathType Leaf) {
$vsConfig = Get-Content -Path $vsConfigPath | ConvertFrom-Json
Expand Down Expand Up @@ -108,7 +117,7 @@ function SetupEnvironment {
Set-Location ".."

Write-Host "Preparing PHP runtime components..."
$executablePath = GetPhpLocation
$executablePath = GetPhpExecutable
if ($executablePath) {
$extensionDir = Join-Path -Path (Split-Path -Path $executablePath) -ChildPath "ext"
$xdebugDir = [IO.Path]::GetFileName((Resolve-Path -Path (Join-Path $extensionDir "php_xdebug*.dll")))
Expand Down Expand Up @@ -139,14 +148,14 @@ function SetupEnvironment {
function InvokeComposer {
Write-Host "Invoking composer $Composer..."
Write-Host ""
$executablePath = GetPhpLocation
$executablePath = GetPhpExecutable
Start-Process -FilePath $executablePath -ArgumentList "-c",".\php.ini",".\composer.phar",$Composer -NoNewWindow -Wait
}

function StartServer {
Write-Host "Starting development server..."
Write-Host ""
$executablePath = GetPhpLocation
$executablePath = (GetPhpExecutable -Ini)
Start-Process -FilePath $executablePath -ArgumentList "-c",".\php.ini","-S","localhost:8080"
}

Expand Down

0 comments on commit 357f1bc

Please sign in to comment.