Skip to content

Commit 00f25ea

Browse files
committed
feat: Add 'whereami' command to display installation locations of phat.bat and phat.ps1
1 parent 5a14221 commit 00f25ea

2 files changed

Lines changed: 66 additions & 1 deletion

File tree

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ Download the latest MSI installer from [Releases](https://github.com/pphatdev/ph
3939
phat help
4040
```
4141

42+
> **Note**: Phat is designed for Windows Command Prompt or PowerShell. If using Git Bash or other bash terminals, see the [Git Bash compatibility guide](docs/git-bash-compatibility.md).
43+
4244
## Commands
4345

4446
### Show version
@@ -198,16 +200,32 @@ dotnet build ./installer/Phat.wixproj -c Release -p:ProductVersion=1.0.0
198200

199201
## Troubleshooting
200202

203+
📖 **For detailed troubleshooting solutions, see [TROUBLESHOOTING.md](docs/TROUBLESHOOTING.md)**
204+
205+
### PowerShell Execution Policy Error
206+
207+
If you see "cannot be loaded. The file is not digitally signed" error:
208+
209+
1. Open PowerShell as Administrator
210+
2. Run: `Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser`
211+
3. Run: `Unblock-File "C:\Program Files (x86)\Phat\phat.ps1"`
212+
213+
➡️ **[Full solution guide](docs/powershell-execution-policy.md)**
214+
201215
### Permission Errors
202216

203217
Run your terminal as **Administrator** if you encounter permission errors when switching PHP versions.
204218

219+
➡️ **[Full solution guide](docs/permission-denied.md)**
220+
205221
### Apache Won't Start
206222

207223
1. Check Apache error logs at `C:\xampp\apache\logs\error.log`
208224
2. Ensure the correct PHP DLL files exist in the PHP directory
209225
3. Verify `httpd-xampp.conf` has the correct PHP module configuration
210226

227+
➡️ **[Full solution guide](docs/apache-wont-start.md)**
228+
211229
### VHost Warnings
212230

213231
Apache virtual host warnings (e.g., `Could not resolve host name`) are unrelated to PHP switching — they come from your virtual host configuration in `httpd-vhosts.conf`.

phat.ps1

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,52 @@ function Show-Version {
200200
Write-Host ""
201201
}
202202

203+
function Show-WhereAmI {
204+
Write-Host ""
205+
Write-Host " Phat Installation Locations:" -ForegroundColor Cyan
206+
Write-Host ""
207+
208+
# Find phat.bat in PATH
209+
$phatBat = $null
210+
$pathDirs = $env:PATH -split ';'
211+
212+
foreach ($dir in $pathDirs) {
213+
if ($dir -and (Test-Path $dir)) {
214+
$batPath = Join-Path $dir "phat.bat"
215+
if (Test-Path $batPath) {
216+
$phatBat = $batPath
217+
break
218+
}
219+
}
220+
}
221+
222+
# Show phat.bat location
223+
if ($phatBat) {
224+
Write-Host " phat.bat:" -ForegroundColor Green
225+
Write-Host " $phatBat" -ForegroundColor White
226+
} else {
227+
Write-Host " phat.bat: " -NoNewline -ForegroundColor Yellow
228+
Write-Host "Not found in PATH" -ForegroundColor Gray
229+
}
230+
231+
# Show current script location
232+
$scriptPath = $PSScriptRoot
233+
if (-not $scriptPath) {
234+
$scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path
235+
}
236+
237+
if ($scriptPath) {
238+
$ps1Path = Join-Path $scriptPath "phat.ps1"
239+
if (Test-Path $ps1Path) {
240+
Write-Host ""
241+
Write-Host " phat.ps1:" -ForegroundColor Green
242+
Write-Host " $ps1Path" -ForegroundColor White
243+
}
244+
}
245+
246+
Write-Host ""
247+
}
248+
203249
function Write-ExampleLine ([string]$CommandText) {
204250
Write-Host " $ " -ForegroundColor DarkGray -NoNewline
205251
Write-Host $CommandText -ForegroundColor Cyan
@@ -228,6 +274,7 @@ function Show-Help {
228274
Write-UsageLine "phat list --php --local" " -> List local PHP versions (same as list)"
229275
Write-UsageLine "phat list --php --global" " -> List available stable versions from PHP.net"
230276
Write-UsageLine "phat current" " -> Show current PHP version"
277+
Write-UsageLine "phat whereami" " -> Show phat.bat installation location"
231278
Write-UsageLine "phat -v | --version" " -> Show Phat version"
232279
Write-UsageLine "phat switch [version]" " -> Switch to a PHP version"
233280
Write-UsageLine "phat use [version]" " -> Alias for switch"
@@ -603,11 +650,11 @@ if ($VersionFlag) {
603650
switch ($Command) {
604651
"list" { Invoke-List }
605652
"current" { Show-CurrentVersion }
653+
"whereami" { Show-WhereAmI }
606654
"switch" { Invoke-Switch $Argument }
607655
"use" { Invoke-Switch $Argument }
608656
"install" { Invoke-Install $Argument }
609657
"uninstall" { Invoke-Uninstall $Argument }
610658
"help" { Show-Help }
611-
612659
default { Show-Help }
613660
}

0 commit comments

Comments
 (0)