@@ -114,22 +114,35 @@ func Use(args []string) {
114114 }
115115 }
116116
117- // remove old bat script
117+ // remove old php bat script
118118 batPath := filepath .Join (binPath , "php.bat" )
119119 if _ , err := os .Stat (batPath ); err == nil {
120120 os .Remove (batPath )
121121 }
122122
123- // remove the old sh script
123+ // remove the old php sh script
124124 shPath := filepath .Join (binPath , "php" )
125125 if _ , err := os .Stat (shPath ); err == nil {
126126 os .Remove (shPath )
127127 }
128128
129+ // remove old php-cgi bat script
130+ batPathCGI := filepath .Join (binPath , "php-cgi.bat" )
131+ if _ , err := os .Stat (batPathCGI ); err == nil {
132+ os .Remove (batPathCGI )
133+ }
134+
135+ // remove old php-cgi sh script
136+ shPathCGI := filepath .Join (binPath , "php-cgi" )
137+ if _ , err := os .Stat (shPathCGI ); err == nil {
138+ os .Remove (shPathCGI )
139+ }
140+
129141 versionFolderPath := filepath .Join (homeDir , ".pvm" , "versions" , selectedVersion .folder .Name ())
130142 versionPath := filepath .Join (versionFolderPath , "php.exe" )
143+ versionPathCGI := filepath .Join (versionFolderPath , "php-cgi.exe" )
131144
132- // create bat script
145+ // create bat script for php
133146 batCommand := "@echo off \n "
134147 batCommand = batCommand + "set filepath=\" " + versionPath + "\" \n "
135148 batCommand = batCommand + "set arguments=%*\n "
@@ -141,7 +154,7 @@ func Use(args []string) {
141154 log .Fatalln (err )
142155 }
143156
144- // create sh script
157+ // create sh script for php
145158 shCommand := "#!/bin/bash\n "
146159 shCommand = shCommand + "filepath=\" " + versionPath + "\" \n "
147160 shCommand = shCommand + "\" $filepath\" \" $@\" "
@@ -152,6 +165,29 @@ func Use(args []string) {
152165 log .Fatalln (err )
153166 }
154167
168+ // create bat script for php-cgi
169+ batCommandCGI := "@echo off \n "
170+ batCommandCGI = batCommandCGI + "set filepath=\" " + versionPathCGI + "\" \n "
171+ batCommandCGI = batCommandCGI + "set arguments=%*\n "
172+ batCommandCGI = batCommandCGI + "%filepath% %arguments%\n "
173+
174+ err = os .WriteFile (batPathCGI , []byte (batCommandCGI ), 0755 )
175+
176+ if err != nil {
177+ log .Fatalln (err )
178+ }
179+
180+ // create sh script for php-cgi
181+ shCommandCGI := "#!/bin/bash\n "
182+ shCommandCGI = shCommandCGI + "filepath=\" " + versionPathCGI + "\" \n "
183+ shCommandCGI = shCommandCGI + "\" $filepath\" \" $@\" "
184+
185+ err = os .WriteFile (shPathCGI , []byte (shCommandCGI ), 0755 )
186+
187+ if err != nil {
188+ log .Fatalln (err )
189+ }
190+
155191 // create directory link to ext directory
156192 extensionDirPath := filepath .Join (versionFolderPath , "ext" )
157193 extensionLinkPath := filepath .Join (binPath , "ext" )
0 commit comments