Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 34f6ef7

Browse files
Merge branch 'feature/default-configs-use' into develop
2 parents 9a86869 + fe6fc7d commit 34f6ef7

File tree

3 files changed

+147
-57
lines changed

3 files changed

+147
-57
lines changed

‎CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
66

77
## [Unreleased]
88

9+
## [1.1.0] - 2018年08月24日
10+
11+
### Added
12+
- Ability to automatically detect WampServer default installation paths (both 32-bit and 64-bit).
13+
- Ability to solely specify WampServer custom installation path.
14+
15+
### Changed
16+
- Updated readme.md
17+
- Fixed spelling mistakes in readme.md
18+
919
## [1.0.0] - 2018年03月23日
1020

1121
### Added

‎README.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,30 @@ At just over 7kB the CLI Changer script is small enough to be saved anywhere in
1414
**Tip:** Once you have save the CLI Changer script, create a desktop shortcut to it for quick and easy access.
1515

1616
## Configuration
17-
If using a WampServer 32-bit version with default settings, then no configuration is necessary.
17+
No configuration is necessary if your installed WampServer in its default directory.
1818

19-
If using a WampServer 64-bit version **OR** a different install path was used during installation, then follow the steps below:
20-
21-
1. Open the CLI Changer script in your preferred text editor.
22-
2. Change the value of the `$pathToInstall` variable to match that of your WampServer installation path. **Note:** If your path has spaces in it then the line should look like this: `"$pathToInstall=C:\wamp server"`
23-
3. Once you have changed the value, save and close your editor.
24-
25-
For your reference, the default WampServer install paths are:
19+
The default installation directories are:
2620
- `C:\wamp` - For 32-bit installations.
2721
- `C:\wamp64` - For 64-bit installations.
2822

23+
If you installed WampServer in a custom directory, then follow the steps below:
24+
25+
1. Open the CLI Changer script in your preferred text editor.
26+
2. Append your custom install path to the `$customInstallPath` variable.
27+
3. Save the file and close your editor.
28+
2929
Example: A customised WampServer install path.
3030
```
3131
rem +------------------------------------------------+
3232
rem | User Defined Variable(s) |
3333
rem +------------------------------------------------+
3434
35-
rem WampServer install path.
36-
set $pathToInstall=D:\WampServer64
35+
rem WampServer custom install path.
36+
set $customInstallPath=D:\WampServer 64-Bit
3737
```
3838

39+
**IMPORTANT:** Do not add quotation marks around your custom installation path, even if the path contains spaces.
40+
3941
## How To Use
4042
There are two ways you can use the CLI Changer script.
4143

@@ -94,7 +96,7 @@ From a Bash or Powershell prompt:
9496
$ start "C:\path\to\cli_changer.bat" php7.2.3
9597
```
9698

97-
**Note 1:** You will need to enclose the CLI Changer script path in double quotation marks if the path contains any spaces.
99+
**Note 1:** You will need to enclose the CLI Changer script path in quotes if the path contains any spaces.
98100

99101
**Note 2:** You will need to know the available PHP CLI version(s) in advance prior to using this command.
100102

@@ -110,7 +112,7 @@ Following execution, an exit code will be given:
110112
As of WampServer v3.1.2 the below error message may be displayed.
111113

112114
```
113-
ERROR C:/wamp or PHP in PATH"
115+
Error C:/wamp or PHP in PATH
114116
```
115117

116118
Clicking on this error will open a command window displaying the below message.
@@ -130,7 +132,7 @@ Wampserver does not use, modify or require the PATH environmental variable.
130132
Using a PATH on Wampserver or PHP version
131133
is detrimental to the proper functioning of Wampserver.
132134
133-
Press ENTER top continue...
135+
Press ENTER to continue...
134136
```
135137

136138
This error can be suppressed by right-clicking the WampServer icon in the taskbar notification area and selecting: _Wamp Settings -> Do not verify PATH_

‎cli_changer.bat

Lines changed: 122 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ rem +------------------------------------------------+
88
rem | User Defined Variable(s) |
99
rem +------------------------------------------------+
1010

11-
rem WampServer install path.
12-
set $pathToInstall=C:\wamp
11+
rem WampServer custom install path.
12+
set $customInstallPath=
1313

1414

1515

@@ -20,9 +20,12 @@ rem +------------------------------------------------+
2020
rem ---------------------
2121
rem Default Variables
2222
rem ---------------------
23-
set $scriptVersion=1.0.0
23+
set $scriptVersion=1.1.0
2424

25-
set $pathToPhps=bin\php\
25+
set $defaultInstallPath[0]=C:\wamp
26+
set $defaultInstallPath[1]=C:\wamp64
27+
28+
set $pathToPhpFolders=bin\php
2629

2730
set $cliMode=0
2831

@@ -31,6 +34,70 @@ set $colorSuccess=0A
3134
set $colorWarning=0E
3235
set $colorFailure=0C
3336

37+
rem Set the title.
38+
title WampServer PHP CLI Version Changer v%$scriptVersion%
39+
40+
41+
rem -----------------
42+
rem Install Paths
43+
rem -----------------
44+
45+
rem Test for a custom install path.
46+
if defined $customInstallPath (
47+
48+
rem Check if the folder exists.
49+
if not exist "%$customInstallPath%" goto invalidCustomInstallPathGiven
50+
51+
set $installPath=%$customInstallPath%
52+
)
53+
54+
rem Test for the first default install path.
55+
if not defined $installPath (
56+
57+
rem Check if the first default install path exists.
58+
if exist %$defaultInstallPath[0]% (
59+
set $installPath=%$defaultInstallPath[0]%
60+
)
61+
)
62+
63+
rem Test for the second default install path.
64+
if not defined $installPath (
65+
66+
rem Check if the second default install path exists.
67+
if exist %$defaultInstallPath[1]% (
68+
set $installPath=%$defaultInstallPath[1]%
69+
)
70+
)
71+
72+
rem Exit if unable to find installation path.
73+
if not defined $installPath goto defaultInstallPathsMissing
74+
75+
76+
rem -------------------
77+
rem PHP Folder Path
78+
rem -------------------
79+
80+
rem Set the $pathToPhpFolders path.
81+
if %$installPath:~-1% neq \ (
82+
set $pathToPhpFolders=%$installPath%\%$pathToPhpFolders%
83+
) else (
84+
set $pathToPhpFolders=%$installPath%%$pathToPhpFolders%
85+
)
86+
87+
rem Check the $pathToPhpFolders path exists.
88+
if not exist "%$pathToPhpFolders%" goto invalidPathToPhpFoldersGiven
89+
90+
rem Iterate through folders in the the $pathToPhpFolders path adding them to the availablePhpVersionsArray.
91+
set counter=0
92+
93+
for /F "delims=" %%a in ('dir %$pathToPhpFolders% /AD /B') do (
94+
set /A counter=counter+1
95+
set $availablePhpVersionsArray[!counter!]=%%a
96+
)
97+
98+
rem Set the last available PHP versions array id.
99+
set $lastAvailablePhpVersionsArrayId=!counter!
100+
34101

35102
rem ----------------------------
36103
rem Users Environmental Path
@@ -57,34 +124,6 @@ rem Set the last users environmental path array id.
57124
set $lastUsersEnvironmentalPathArrayId=!counter!
58125

59126

60-
rem ---------------------------------
61-
rem Available PHP Folder Versions
62-
rem ---------------------------------
63-
64-
rem Set the $pathToPhps path.
65-
if %$pathToInstall:~-1% neq \ (
66-
set $pathToPhps=%$pathToInstall%\%$pathToPhps%
67-
) else (
68-
set $pathToPhps=%$pathToInstall%%$pathToPhps%
69-
)
70-
71-
rem Check the $pathToPhps path exists.
72-
PUSHD %$pathToPhps% && POPD || (
73-
goto invalidPathToPhpsGiven
74-
)
75-
76-
rem Iterate through folders in the the $pathToPhps path adding them to the availablePhpVersionsArray.
77-
set counter=0
78-
79-
for /F "delims=" %%a in ('dir %$pathToPhps% /AD /B') do (
80-
set /A counter=counter+1
81-
set $availablePhpVersionsArray[!counter!]=%%a
82-
)
83-
84-
rem Set the last available PHP versions array id.
85-
set $lastAvailablePhpVersionsArrayId=!counter!
86-
87-
88127
rem ----------------------------
89128
rem Match PHP Folder Version
90129
rem ----------------------------
@@ -99,7 +138,7 @@ for /L %%a in (1,1,%$lastUsersEnvironmentalPathArrayId%) do (
99138
rem Loop through the $availablePhpVersionsArray.
100139
for /L %%b in (1,1,%$lastAvailablePhpVersionsArrayId%) do (
101140
rem Check if the users environmental path string matches the path to the available PHP version string.
102-
if "!$usersEnvironmentalPathArray[%%a]!"=="%$pathToPhps%!$availablePhpVersionsArray[%%b]!" (
141+
if "!$usersEnvironmentalPathArray[%%a]!"=="%$pathToPhpFolders%!$availablePhpVersionsArray[%%b]!" (
103142
rem Force the 'for' command parameters into type 'integer'.
104143
set /A $currentPhpVersionId=currentPhpVersionId+%%b
105144
set /A $currentUserEnvPathId=$currentUserEnvPathId+%%a
@@ -146,17 +185,15 @@ rem Display PHP Versions
146185
rem ------------------------
147186

148187
rem Set the window.
149-
title WampServer PHP CLI Version Changer v%$scriptVersion%
150188
color %$colorNormal%
151189

152-
153-
rem Show the title.
190+
rem Show the header.
154191
echo:
155192
echo Available PHP CLI Versions
156193
echo --------------------------
157194
echo:
158195

159-
rem Display all available list of PHP folder names.
196+
rem List all installed PHP folder names.
160197
for /L %%a in (1,1,%$lastAvailablePhpVersionsArrayId%) do (
161198
if %%a equ %$currentPhpVersionId% (
162199
echo %%a - !$availablePhpVersionsArray[%%a]! - Current
@@ -201,15 +238,15 @@ for /L %%a in (1,1,%$lastUsersEnvironmentalPathArrayId%) do (
201238
)
202239

203240
rem Add the selected PHP folder path to the end of the $usersEnvironmentalPathString.
204-
set $result=%$result%%$pathToPhps%!$availablePhpVersionsArray[%$newSelectionId%]!
241+
set $result=%$result%%$pathToPhpFolders%!$availablePhpVersionsArray[%$newSelectionId%]!
205242

206243
rem Set the $usersEnvironmentalPathString.
207244
setx path "%$result%" >nul
208245

209246

210-
rem --------------------
211-
rem Exit Subroutines
212-
rem --------------------
247+
rem ------------------------------
248+
rem Exit Subroutines - Success
249+
rem ------------------------------
213250

214251
rem The update was successful.
215252
:updateSuccessful
@@ -237,6 +274,11 @@ if %$cliMode% equ 0 (
237274

238275
exit 0
239276

277+
278+
rem ------------------------------
279+
rem Exit Subroutines - Failure
280+
rem ------------------------------
281+
240282
rem An invalid selection was given.
241283
:invalidSelectionGiven
242284

@@ -250,13 +292,49 @@ if %$cliMode% equ 0 (
250292

251293
exit 1
252294

253-
rem An invalid $pathToPhps was given.
254-
:invalidPathToPhpsGiven
295+
rem ----------------------------
296+
rem Exit Subroutines - Error
297+
rem ----------------------------
298+
299+
rem An invalid $customInstallPath was given.
300+
:invalidCustomInstallPathGiven
301+
302+
if %$cliMode% equ 0 (
303+
color %$colorFailure%
304+
echo:
305+
echo The $customInstallPath path "%$customInstallPath%" does not exist.
306+
echo:
307+
echo Press any key to exit.
308+
pause >nul
309+
)
310+
311+
exit 1
312+
313+
rem Both of the default install paths are missing.
314+
:defaultInstallPathsMissing
315+
if %$cliMode% equ 0 (
316+
color %$colorFailure%
317+
echo:
318+
echo Neither of the default install paths exists.
319+
echo:
320+
echo 1. %$defaultInstallPath[0]%
321+
echo 2. %$defaultInstallPath[1]%
322+
echo:
323+
echo Wampserver does not appear to be installed.
324+
echo:
325+
echo Press any key to exit.
326+
pause >nul
327+
)
328+
329+
exit 1
330+
331+
rem An invalid $pathToPhpFolders was given.
332+
:invalidPathToPhpFoldersGiven
255333

256334
if %$cliMode% equ 0 (
257335
color %$colorFailure%
258336
echo:
259-
echo The $pathToPhps path "%$pathToPhps%" does not exist.
337+
echo The $pathToPhpFolders path "%$pathToPhpFolders%" does not exist.
260338
echo:
261339
echo See the WampServer website for help.
262340
echo:

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /