From 2723d2f5b6770d12292fe37d31c1506cd449dcc4 Mon Sep 17 00:00:00 2001 From: Marco Milon Date: Sun, 6 Dec 2020 17:55:56 -0500 Subject: [PATCH] Upgrade to php 7.4.13 --- README.md | 4 ++-- internal/php/installer.go | 18 +++++++++++------- main.go | 4 ++-- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 89f9d6c..cd44ba8 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,11 @@ EzPHP gives you a personal PHP webserver for development. The goal of the project is to provide a single **.exe** file that will get you a ready to use PHP development environment. -EzPHP will install PHP v. 7.4.10 downloaded from https://windows.php.net/downloads/releases/php-7.4.10-nts-Win32-vc15-x64.zip +EzPHP will install PHP v. 7.4.13 downloaded from https://windows.php.net/downloads/releases/php-7.4.13-nts-Win32-vc15-x64.zip ### Installation -1. Download [ezphp.zip](https://github.com/marcomilon/ezphp/releases/download/1.2.0/ezphp.zip). +1. Download [ezphp.zip](https://github.com/marcomilon/ezphp). 2. Create a new folder for your project and copy ezphp.exe. 3. Run ezphp.exe. If PHP is not installed locally ezphp will try to download and install PHP. 4. Open your browser in http://localhost:8080. diff --git a/internal/php/installer.go b/internal/php/installer.go index 9f73544..a5afa3a 100644 --- a/internal/php/installer.go +++ b/internal/php/installer.go @@ -31,7 +31,7 @@ func FastInstall(source, installFolder string) (string, error) { var confirmation string - fmt.Print("Would you like to install PHP version 7.4.10? [y/N] ") + fmt.Print("Would you like to install PHP version 7.4.13? [y/N] ") fmt.Scanln(&confirmation) confirmation = strings.TrimSpace(confirmation) @@ -68,6 +68,16 @@ func download(source, installFolder string) (string, error) { filename := path.Base(source) + resp, err := http.Get(source) + if err != nil { + return "", err + } + defer resp.Body.Close() + + if resp.StatusCode != 200 { + return "", fmt.Errorf("error %d\n", resp.StatusCode) + } + if _, err := os.Stat(installFolder); os.IsNotExist(err) { err = os.MkdirAll(installFolder, 0755) if err != nil { @@ -75,12 +85,6 @@ func download(source, installFolder string) (string, error) { } } - resp, err := http.Get(source) - if err != nil { - return "", err - } - defer resp.Body.Close() - out, err := os.Create(installFolder + string(os.PathSeparator) + filename) if err != nil { return "", err diff --git a/main.go b/main.go index d30e7e2..f293541 100644 --- a/main.go +++ b/main.go @@ -13,8 +13,8 @@ import ( const ( ezPHPWebsite = "https://github.com/marcomilon/ezphp" - downloadURL = "https://windows.php.net/downloads/releases/php-7.4.10-nts-Win32-vc15-x64.zip" - installFolder = "php-7.4.10" + downloadURL = "https://windows.php.net/downloads/releases/php-7.4.13-nts-Win32-vc15-x64.zip" + installFolder = "php-7.4.13" ) func main() {