Skip to content

Commit

Permalink
Add some more logging to help debugging issues
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Jan 23, 2022
1 parent 367e020 commit 28d59d1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
3 changes: 1 addition & 2 deletions commands/local_new.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,16 +367,15 @@ func getSpecialVersion(version string) (string, error) {
}

func forcePHPVersion(v, dir string) (string, error) {
store := phpstore.New(util.GetHomeDir(), true, nil)
if v == "" {
store := phpstore.New(util.GetHomeDir(), true, nil)
minor, _, _, err := store.BestVersionForDir(dir)
return strings.Join(strings.Split(minor.Version, ".")[0:2], "."), err
}
if _, err := version.NewVersion(v); err != nil {
return "", errors.Errorf("unable to parse PHP version \"%s\"", v)
}
// check that the version is available
store := phpstore.New(util.GetHomeDir(), true, nil)
if !store.IsVersionAvailable(v) {
return "", errors.Errorf("PHP version \"%s\" is not available locally", v)
}
Expand Down
7 changes: 5 additions & 2 deletions commands/local_server_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,12 @@ func printWebServerStatus(projectDir string) error {
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)
homeDir := util.GetHomeDir()
phpStore := phpstore.New(homeDir, true, nil)
version, _, _, err := phpStore.BestVersionForDir(projectDir)
version, source, warning, err := phpStore.BestVersionForDir(projectDir)
if err == nil {
terminal.Printfln(" The Web server is using <info>%s %s</>", version.ServerTypeName(), version.Version)
terminal.Printfln(" The Web server is using <info>%s %s</> (from %s)", version.ServerTypeName(), version.Version, source)
if warning != "" {
terminal.Printfln(" <warning>WARNING</> %s", warning)
}
}
terminal.Println()
terminal.Println("<info>Local Domains</>")
Expand Down
2 changes: 2 additions & 0 deletions local/php/composer.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (

"github.com/pkg/errors"
"github.com/symfony-cli/symfony-cli/util"
"github.com/symfony-cli/terminal"
)

const DefaultComposerVersion = 2
Expand Down Expand Up @@ -63,6 +64,7 @@ func Composer(dir string, args, env []string, stdout, stderr, logger io.Writer)
Stderr: stderr,
SkipNbArgs: -1,
ExtraEnv: env,
Logger: terminal.Logger,
}

composerBin := "composer1"
Expand Down
5 changes: 4 additions & 1 deletion local/php/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (

"github.com/pkg/errors"
"github.com/rs/xid"
"github.com/rs/zerolog"
"github.com/symfony-cli/phpstore"
"github.com/symfony-cli/symfony-cli/envs"
"github.com/symfony-cli/symfony-cli/util"
Expand All @@ -51,6 +52,7 @@ type Executor struct {
Stdin io.Reader
Paths []string
ExtraEnv []string
Logger zerolog.Logger

environ []string
iniDir string
Expand All @@ -76,13 +78,14 @@ func GetBinaryNames() []string {

func (e *Executor) lookupPHP(cliDir string, forceReload bool) (*phpstore.Version, string, bool, error) {
phpStore := phpstore.New(cliDir, forceReload, nil)
v, _, warning, err := phpStore.BestVersionForDir(e.scriptDir)
v, source, warning, err := phpStore.BestVersionForDir(e.scriptDir)
if warning != "" {
terminal.Eprintfln("<warning>WARNING</> %s", warning)
}
if err != nil {
return nil, "", true, err
}
e.Logger.Debug().Str("source", "PHP").Msgf("Using PHP version %s (from %s)", v.Version, source)
path := v.PHPPath
phpiniArgs := true
if e.BinName == "php-fpm" {
Expand Down

0 comments on commit 28d59d1

Please sign in to comment.