Skip to content

Commit

Permalink
Use socket as env var for enabling Blackfire on local web server
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Feb 11, 2022
1 parent 1261bda commit 53e0823
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 100 deletions.
4 changes: 1 addition & 3 deletions envs/envs.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,7 @@ func extractRelationshipsEnvs(env Environment) Envs {
values[fmt.Sprintf("%sSCHEME", prefix)] = endpoint["scheme"].(string)
values[fmt.Sprintf("%sHOST", prefix)] = endpoint["host"].(string)
if rel == "blackfire" {
// FIXME: That does not work yet as Blackfire does not support it for now
// Once fixed, we will be able to remove the ini settings set in local/php/envs.go
// values["BLACKFIRE_AGENT_SOCKET"] = values[fmt.Sprintf("%sURL", prefix)]
values["BLACKFIRE_AGENT_SOCKET"] = values[fmt.Sprintf("%sURL", prefix)]
}
} else if rel == "mercure" {
values["MERCURE_URL"] = fmt.Sprintf("%s://%s:%s/.well-known/mercure", endpoint["scheme"].(string), endpoint["host"].(string), formatInt(endpoint["port"]))
Expand Down
29 changes: 0 additions & 29 deletions local/php/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,13 @@ package php
import (
"fmt"
"io"
"io/ioutil"
"math/rand"
"os"
"os/exec"
"os/signal"
"path/filepath"
"runtime"
"strings"
"syscall"
"time"

"github.com/pkg/errors"
"github.com/rs/xid"
Expand Down Expand Up @@ -247,11 +244,6 @@ func (e *Executor) Config(loadDotEnv bool) error {
}
e.Paths = append([]string{path}, e.Paths...)
if phpiniArgs {
wd, _ := os.Getwd()
e.iniDir, err = e.generateLocalPhpIniFile(wd, cliDir)
if err != nil {
return err
}
// see https://php.net/manual/en/configuration.file.php
// if PHP_INI_SCAN_DIR exists, just append our new directory
// if not, add the default one (empty string) and then our new directory
Expand Down Expand Up @@ -412,27 +404,6 @@ func LookPath(file string) (string, error) {
return exec.LookPath(file)
}

func (e *Executor) generateLocalPhpIniFile(wd, cliDir string) (string, error) {
rand.Seed(time.Now().UnixNano())
tmpDir := filepath.Join(cliDir, "var", fmt.Sprintf("%s_%d", name(wd), rand.Intn(99999999)))
os.RemoveAll(tmpDir)
if err := os.MkdirAll(tmpDir, 0755); err != nil {
return "", errors.Errorf("unable to create temp dir %s", tmpDir)
}
ini := GetPHPINISettings(e.scriptDir).Bytes()
// don't write an empty ini file as it might be read as a non-valid ini file by PHP (and Composer)
if len(ini) > 0 {
extraIni := filepath.Join(tmpDir, "1-extra.ini")
if err := ioutil.WriteFile(extraIni, ini, 0666); err != nil {
os.RemoveAll(tmpDir)
return "", errors.Wrapf(err, "unable to create temp file \"%s\"", extraIni)
}
return tmpDir, nil
}
os.RemoveAll(tmpDir)
return "", nil
}

// detectScriptDir tries to get the script directory from args
func detectScriptDir(args []string) string {
script := ""
Expand Down
68 changes: 0 additions & 68 deletions local/php/settings.go

This file was deleted.

0 comments on commit 53e0823

Please sign in to comment.