package main import ( "bytes" "encoding/json" "fmt" "os" "strings" _ "embed" "github.com/laravel-ls/go-php" ) //go:embed configs.php var source []byte type Entry struct { Value string `json:"value"` File string `json:"file"` Line int `json:"line"` } // call with ./prog /path/to/laravel/project app.key for example. func main() { if len(os.Args) < 2 { fmt.Printf("usage: %s \n", os.Args[0]) os.Exit(1) } php.Init() defer php.Exit() prog, err := php.Compile(source) if err != nil { panic(err) } defer prog.Free() buffer := bytes.Buffer{} php.Output(&buffer).SetPath(os.Args[1]).Exec(prog) data := map[string]Entry{} json.NewDecoder(&buffer).Decode(&data) for name, ent := range data { if strings.HasPrefix(name, os.Args[2]) { fmt.Println("Name:", name) fmt.Println("File:", ent.File) fmt.Println("Value:", ent.Value) fmt.Println("---") } } }