Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/chocolatey_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish chocolatey package

on:
release:
types: [published]

jobs:
publish:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Chocolatey-AU
shell: pwsh
run: Install-Module Chocolatey-AU -Force -Scope CurrentUser

- name: Run update.ps1
shell: pwsh
env:
CHOCO_API_KEY: ${{ secrets.CHOCO_API_KEY }}
working-directory: ./php-pvm
run: .\update.ps1
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Harry Bayliss
Copyright (c) 2025 Harry Bayliss

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ This utility changes that.

## Installation

### Chocolatey

If you want to install pvm without configuring any settings and setting PATH variables, then you can install pvm via [Chocolatey](https://community.chocolatey.org/packages/php-pvm).

Ensure that [Chocolatey](https://chocolatey.org/) is installed on your system.

You can easily install PVM using Chocolatey. Run the following command in a command prompt or PowerShell with administrative rights:

```shell
choco install php-pvm
```

### Manual

Download the latest pvm version from the releases page (1.0-alpha-1, it's currently a pre-release).

Create the folder `%UserProfile%\.pvm\bin` (e.g. `C:\Users\Harry\.pvm\bin`) and drop the pvm exe in there. Add the folder to your PATH.
Expand Down
28 changes: 28 additions & 0 deletions php-pvm/php-pvm.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Do not remove this test for UTF-8: if “Ω” doesn’t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. -->
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>php-pvm</id>
<version>1.2.1</version>
<packageSourceUrl>https://github.com/tschogge/php-pvm</packageSourceUrl>
<!-- == SOFTWARE SPECIFIC SECTION == -->
<!-- This section is about the software itself -->
<title>pvm</title>
<authors>hjbdev,Lotti,ENG3PLabs,oldreposcrapyard,goodjun,OliverWich,EbouBaker</authors>
<owners>Tschogge</owners>
<projectUrl>https://github.com/hjbdev/pvm</projectUrl>
<docsUrl>https://github.com/hjbdev/pvm</docsUrl>
<projectSourceUrl>https://github.com/hjbdev/pvm</projectSourceUrl>
<licenseUrl>https://github.com/hjbdev/pvm/blob/master/LICENSE</licenseUrl>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<mailingListUrl>https://github.com/hjbdev/pvm/discussions</mailingListUrl>
<bugTrackerUrl>https://github.com/hjbdev/pvm/discussions</bugTrackerUrl>
<tags>pvm php php-version php-version-manager manager phpversion phpversionmanager</tags>
<summary>A PHP version manager</summary>
<description>A PHP version manager to simply install different PHP versions and easily switch between them. Similar to nvm. Use pvm in the terminal after installation to get started. Repo: https://github.com/hjbdev/pvm</description>
</metadata>
<files>
<!-- this section controls what actually gets packaged into the Chocolatey package -->
<file src="tools\**" target="tools" />
</files>
</package>
36 changes: 36 additions & 0 deletions php-pvm/tools/chocolateyinstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
$ErrorActionPreference = 'Stop'
$toolName = 'pvm'
$userDataPath = [Environment]::GetFolderPath('UserProfile')
$targetPath = "$userDataPath\.$toolName\bin"
$url64 = 'https://github.com/hjbdev/pvm/releases/download/1.2.0/pvm.exe'
$checksum64 = 'A764F8C2EE58EE4A5B026EEEDEFC044F1C4E3802CA96E4E8D00AF3E6504E831F'


if (!(Test-Path $targetPath)) {
New-Item -ItemType Directory -Path $targetPath -Force
Write-Host "Created directory $targetPath"
}

Install-ChocolateyPath -Path $targetPath -PathType 'Machine'
Write-Host "Added $targetPath to the system PATH"

$tempFile = "$env:TEMP\pvm.exe"
$packageArgs = @{
packageName = $env:ChocolateyPackageName
fileType = 'EXE'
url64bit = $url64
softwareName = "$toolName*"
checksum64 = $checksum64
checksumType64 = 'sha256'
file = $tempFile
}

Get-ChocolateyWebFile @packageArgs

Copy-Item -Path $tempFile -Destination "$targetPath\$toolName.exe" -Force
Write-Host "Copied $toolName.exe to $targetPath"

if (!(Test-Path "$targetPath\$toolName.exe")) {
Write-Error "Failed to copy pvm.exe to $targetPath"
exit 1
}
17 changes: 17 additions & 0 deletions php-pvm/tools/chocolateyuninstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
$ErrorActionPreference = 'Stop'
$toolName = "pvm"
$userDataPath = [Environment]::GetFolderPath('UserProfile')
$targetPath = "$userDataPath\.$toolName"

if (Test-Path $targetPath) {
Remove-Item $targetPath -Force -Recurse
Write-Host "Removed the directory and all its contents from $targetPath"
}

Uninstall-ChocolateyPath -Path "$targetPath\bin" -PathType "Machine"
Write-Host "Removed $targetPath\bin from the system PATH"

if (Test-Path "$targetPath\$toolName.exe") {
Write-Host "Failed to remove $targetPath\$toolName.exe"
exit 1
}
37 changes: 37 additions & 0 deletions php-pvm/update.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Import-Module Chocolatey-AU

function global:au_BeforeUpdate {
$Latest.Checksum64 = Get-RemoteChecksum $Latest.URL64
}

function global:au_GetLatest {
$latestRelease = Invoke-RestMethod -UseBasicParsing -Uri 'https://api.github.com/repos/hjbdev/pvm/releases/latest'

return @{
URL64 = $latestRelease.assets.browser_download_url
Version = $latestRelease.tag_name
ChecksumType64 = 'sha256'
Description = 'A PHP version manager to simply install different PHP versions and easily switch between them. Similar to nvm. Use pvm in the terminal after installation to get started. Repo: https://github.com/hjbdev/pvm'
}
}

function global:au_SearchReplace {
@{
".\tools\chocolateyInstall.ps1" = @{
"(^[$]url64\s*=\s*)('.*')" = "`$1'$($Latest.URL64)'"
"(^[$]checksum64\s*=\s*)('.*')" = "`$1'$($Latest.Checksum64)'"
"(^\s*checksumType64\s*=\s*)('.*')" = "`$1'$($Latest.ChecksumType64)'"
}

"php-pvm.nuspec" = @{
"(\<version\>).*?(\</version\>)" = "`${1}$($Latest.Version)`$2"
}

}
}

function global:au_AfterUpdate ($Package) {
choco push $Package.NuspecPath --api-key=$Env:CHOCO_API_KEY
}

update -ChecksumFor none -NoReadme