Last active
September 7, 2017 20:23
-
-
Save kryshac/2d70f7eabfb940edee6454190e4972a8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Hello | |
| write-host "Hello. This script will install php-cs-fixer for you." -foregroundcolor DarkGreen -backgroundcolor white | |
| $PSVersionTable.PSVersion | |
| #functions and variables | |
| if ($env:TEMP -eq $null) { | |
| $env:TEMP = Join-Path $env:SystemDrive 'temp' | |
| } | |
| if (![System.IO.Directory]::Exists($env:TEMP)) { | |
| Write-Host "Creating temporary download directory in env:TEMP" -foregroundcolor DarkBlue -backgroundcolor white | |
| [System.IO.Directory]::CreateDirectory($env:TEMP) | |
| } | |
| $php_path = Join-Path $env:WINDIR "php" | |
| #download stuff | |
| $url1 = "http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar" | |
| $file1 = Join-Path $env:TEMP "php-cs-fixer" | |
| Write-Host "--> Downloading $url1 to $file1" -foregroundcolor DarkRed -backgroundcolor white | |
| wget $url1 -Outfile $file1 | |
| $url2 = "http://windows.php.net/downloads/releases/php-7.1.9-Win32-VC14-x86.zip" | |
| $file2 = Join-Path $env:TEMP "php.zip" | |
| Write-Host "--> Downloading $url2 to $file2" -foregroundcolor DarkRed -backgroundcolor white | |
| wget $url2 -Outfile $file2 | |
| #Copy php-cs-fixer | |
| Write-Host "Copying php-cs-fixer to $env:WINDIR" -foregroundcolor DarkBlue -backgroundcolor white | |
| copy-item $file1 "$env:WINDIR" | |
| #Create directory for php installation if it doesn't yet exist | |
| if (![System.IO.Directory]::Exists($php_path)) { | |
| Write-Host "Createing directory for php installation in $php_path" -foregroundcolor DarkBlue -backgroundcolor white | |
| [System.IO.Directory]::CreateDirectory($php_path) | |
| } | |
| #unzip and copy (overwriting) | |
| Write-Host "Unzipping php installation to $php_path" -foregroundcolor DarkBlue -backgroundcolor white | |
| $shell_app=new-object -com shell.application | |
| $zip_file = $shell_app.namespace($file2) | |
| $destination = $shell_app.namespace($php_path) | |
| $destination.Copyhere($zip_file.items(), 0x14) | |
| #Add php directory to USERS path variable | |
| Write-Host "Adding php to environment" -foregroundcolor DarkBlue -backgroundcolor white | |
| setx PATH "$env:path;$php_path" | |
| #Cleaning temp stuff | |
| Write-Host "Removing temporary files..." -foregroundcolor DarkRed -backgroundcolor white | |
| rm $file1 | |
| rm $file2 | |
| #Wait for user input to terminate | |
| Write-Host "All done! Bye for now." -foregroundcolor DarkGreen -backgroundcolor white | |
| pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment