Skip to content

Commit 28d59d1

Browse files
committed
Add some more logging to help debugging issues
1 parent 367e020 commit 28d59d1

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

commands/local_new.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,16 +367,15 @@ func getSpecialVersion(version string) (string, error) {
367367
}
368368

369369
func forcePHPVersion(v, dir string) (string, error) {
370+
store := phpstore.New(util.GetHomeDir(), true, nil)
370371
if v == "" {
371-
store := phpstore.New(util.GetHomeDir(), true, nil)
372372
minor, _, _, err := store.BestVersionForDir(dir)
373373
return strings.Join(strings.Split(minor.Version, ".")[0:2], "."), err
374374
}
375375
if _, err := version.NewVersion(v); err != nil {
376376
return "", errors.Errorf("unable to parse PHP version \"%s\"", v)
377377
}
378378
// check that the version is available
379-
store := phpstore.New(util.GetHomeDir(), true, nil)
380379
if !store.IsVersionAvailable(v) {
381380
return "", errors.Errorf("PHP version \"%s\" is not available locally", v)
382381
}

commands/local_server_status.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,12 @@ func printWebServerStatus(projectDir string) error {
6262
terminal.Printfln(" Listening on <href=%s://127.0.0.1:%d>%s://127.0.0.1:%d</>", pidFile.Scheme, pidFile.Port, pidFile.Scheme, pidFile.Port)
6363
homeDir := util.GetHomeDir()
6464
phpStore := phpstore.New(homeDir, true, nil)
65-
version, _, _, err := phpStore.BestVersionForDir(projectDir)
65+
version, source, warning, err := phpStore.BestVersionForDir(projectDir)
6666
if err == nil {
67-
terminal.Printfln(" The Web server is using <info>%s %s</>", version.ServerTypeName(), version.Version)
67+
terminal.Printfln(" The Web server is using <info>%s %s</> (from %s)", version.ServerTypeName(), version.Version, source)
68+
if warning != "" {
69+
terminal.Printfln(" <warning>WARNING</> %s", warning)
70+
}
6871
}
6972
terminal.Println()
7073
terminal.Println("<info>Local Domains</>")

local/php/composer.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434

3535
"github.com/pkg/errors"
3636
"github.com/symfony-cli/symfony-cli/util"
37+
"github.com/symfony-cli/terminal"
3738
)
3839

3940
const DefaultComposerVersion = 2
@@ -63,6 +64,7 @@ func Composer(dir string, args, env []string, stdout, stderr, logger io.Writer)
6364
Stderr: stderr,
6465
SkipNbArgs: -1,
6566
ExtraEnv: env,
67+
Logger: terminal.Logger,
6668
}
6769

6870
composerBin := "composer1"

local/php/executor.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535

3636
"github.com/pkg/errors"
3737
"github.com/rs/xid"
38+
"github.com/rs/zerolog"
3839
"github.com/symfony-cli/phpstore"
3940
"github.com/symfony-cli/symfony-cli/envs"
4041
"github.com/symfony-cli/symfony-cli/util"
@@ -51,6 +52,7 @@ type Executor struct {
5152
Stdin io.Reader
5253
Paths []string
5354
ExtraEnv []string
55+
Logger zerolog.Logger
5456

5557
environ []string
5658
iniDir string
@@ -76,13 +78,14 @@ func GetBinaryNames() []string {
7678

7779
func (e *Executor) lookupPHP(cliDir string, forceReload bool) (*phpstore.Version, string, bool, error) {
7880
phpStore := phpstore.New(cliDir, forceReload, nil)
79-
v, _, warning, err := phpStore.BestVersionForDir(e.scriptDir)
81+
v, source, warning, err := phpStore.BestVersionForDir(e.scriptDir)
8082
if warning != "" {
8183
terminal.Eprintfln("<warning>WARNING</> %s", warning)
8284
}
8385
if err != nil {
8486
return nil, "", true, err
8587
}
88+
e.Logger.Debug().Str("source", "PHP").Msgf("Using PHP version %s (from %s)", v.Version, source)
8689
path := v.PHPPath
8790
phpiniArgs := true
8891
if e.BinName == "php-fpm" {

0 commit comments

Comments
 (0)