File tree Expand file tree Collapse file tree 3 files changed +72
-1
lines changed Expand file tree Collapse file tree 3 files changed +72
-1
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,23 @@ Currently supported PHP versions are:
24
24
8.1
25
25
8.2
26
26
27
- # Contributing
27
+ ### Editing php.ini file
28
+
29
+ You can edit the php.ini file for the current PHP version by running the following command:
30
+
31
+ ``` cmd
32
+ php-ch ini
33
+ ```
34
+
35
+ ### Editing php.ini file for a specific PHP version
36
+
37
+ You can edit the php.ini file for a specific PHP version by running the following command:
38
+
39
+ ``` cmd
40
+ php-ch ini [version]
41
+ ```
42
+
43
+ ## Contributing
28
44
29
45
Feel free to open an issue or a pull request if you have any suggestions or bug reports.
30
46
Original file line number Diff line number Diff line change
1
+ package ch
2
+
3
+ import (
4
+ "fmt"
5
+ "os/exec"
6
+
7
+ "github.com/BrainBuzzer/php-ch/pkg"
8
+ "github.com/spf13/cobra"
9
+ )
10
+
11
+ var iniCommand = & cobra.Command {
12
+ Use : "ini" ,
13
+ Short : "Edit php.ini file" ,
14
+ Long : `Edit php.ini file` ,
15
+ Args : func (cmd * cobra.Command , args []string ) error {
16
+ if len (args ) > 1 {
17
+ return fmt .Errorf ("too many arguments" )
18
+ } else if len (args ) == 1 {
19
+ switch args [0 ] {
20
+ case "7.4" , "8.0" , "8.1" , "8.2" :
21
+ return nil
22
+ default :
23
+ return fmt .Errorf ("invalid version: %s" , args [0 ])
24
+ }
25
+ }
26
+ return nil
27
+ },
28
+ Run : func (cmd * cobra.Command , args []string ) {
29
+ exepath := "C:\\ Windows\\ system32\\ notepad.exe"
30
+
31
+ defaultIniPath := "C:\\ Program Files\\ php\\ php.ini"
32
+ if len (args ) == 1 {
33
+ // open php.ini of specific version
34
+ iniPath := pkg .GetVersionPath (args [0 ]) + "\\ php.ini"
35
+ err := exec .Command (exepath , iniPath ).Run ()
36
+ if err != nil {
37
+ fmt .Println (err )
38
+ }
39
+ }
40
+
41
+ // open default php.ini
42
+ err := exec .Command (exepath , defaultIniPath ).Run ()
43
+ if err != nil {
44
+ fmt .Println (err )
45
+ }
46
+ },
47
+ }
48
+
49
+ func init () {
50
+ rootCmd .AddCommand (iniCommand )
51
+ }
Original file line number Diff line number Diff line change @@ -70,6 +70,10 @@ func DownloadVersion(version string) {
70
70
}
71
71
}
72
72
73
+ func GetVersionPath (version string ) string {
74
+ return filepath .Join (env .Root , "versions" , version )
75
+ }
76
+
73
77
func downloadAndInstall (url string , version string ) {
74
78
req , _ := http .NewRequest ("GET" , url , nil )
75
79
resp , _ := http .DefaultClient .Do (req )
You can’t perform that action at this time.
0 commit comments