|
| 1 | +<# |
| 2 | +.Synopsis |
| 3 | +Installs PHP nightly. |
| 4 | +.Description |
| 5 | +Download and installs a nightly version of PHP. |
| 6 | +.Parameter Architecture |
| 7 | +The architecture of the PHP to be installed (x86 for 32-bit, x64 for 64-bit). |
| 8 | +.Parameter ThreadSafe |
| 9 | +A boolean value to indicate if the Thread-Safe version should be installed or not. |
| 10 | +You usually install the ThreadSafe version if you plan to use PHP with Apache, or the NonThreadSafe version if you'll use PHP in CGI mode. |
| 11 | +.Parameter Path |
| 12 | +The path of the directory where PHP will be installed. |
| 13 | + #> |
| 14 | +param ( |
| 15 | + [Parameter(Mandatory = $true, Position = 1, HelpMessage = 'Architecture of the PHP to be installed (x86 for 32-bit, x64 for 64-bit)')] |
| 16 | + [ValidateSet('x86', 'x64')] |
| 17 | + [string] $Architecture, |
| 18 | + [Parameter(Mandatory = $true, Position = 2, HelpMessage = 'Install a Thread-Safe version?')] |
| 19 | + [bool] $ThreadSafe, |
| 20 | + [Parameter(Mandatory = $true, Position = 3, HelpMessage = 'The path of the directory where PHP will be installed')] |
| 21 | + [ValidateLength(1, [int]::MaxValue)] |
| 22 | + [string] $Path |
| 23 | +) |
| 24 | +if(-not(Test-Path $Path)) { |
| 25 | + New-Item -Type 'directory' $Path |
| 26 | +} |
| 27 | +$ts = 'nts' |
| 28 | +if($ThreadSafe) { |
| 29 | + $ts = 'ts' |
| 30 | +} |
| 31 | +Invoke-WebRequest -UseBasicParsing -Uri "https://dl.bintray.com/shivammathur/php/php-master-$ts-windows-vs16-$Architecture.zip" -OutFile $Path\master.zip |
| 32 | +Expand-Archive -Path $Path\master.zip -DestinationPath $Path -Force |
| 33 | +Copy-Item $Path\php.ini-production -Destination $Path\php.ini |
| 34 | +"xdebug", "pcov" | ForEach-Object { Invoke-WebRequest -UseBasicParsing -Uri "https://github.com/shivammathur/php-extensions-windows/releases/latest/download/php_$ts`_$Architecture`_$_.dll" -OutFile $Path"\ext\php`_$_.dll" } |
| 35 | +$ini_content = @" |
| 36 | +extension_dir=$Path\ext |
| 37 | +default_charset=UTF-8 |
| 38 | +zend_extension=php_opcache.dll |
| 39 | +opcache.jit_buffer_size=256M |
| 40 | +opcache.jit=1235 |
| 41 | +"@ |
| 42 | +Add-Content -Path $Path\php.ini -Value $ini_content |
0 commit comments