(app *DdevApp)
| 17 | } |
| 18 | |
| 19 | func cakephpPostStartAction(app *DdevApp) error { |
| 20 | // We won't touch env if disable_settings_management: true |
| 21 | if app.DisableSettingsManagement { |
| 22 | return nil |
| 23 | } |
| 24 | envFileName := "config/.env" |
| 25 | envFilePath := filepath.Join(app.AppRoot, app.ComposerRoot, envFileName) |
| 26 | _, _, err := ReadProjectEnvFile(envFilePath) |
| 27 | if err != nil && !os.IsNotExist(err) { |
| 28 | return fmt.Errorf("unable to read .env file in config folder: %v", err) |
| 29 | } |
| 30 | if err == nil { |
| 31 | envFileName = "config/.env.ddev" |
| 32 | envFilePath = filepath.Join(app.AppRoot, app.ComposerRoot, envFileName) |
| 33 | _, _, err = ReadProjectEnvFile(envFilePath) |
| 34 | if err == nil { |
| 35 | util.Warning("CakePHP: .env.ddev file exists already. Replacing it. You can rename it or copy settings to your .env file.") |
| 36 | } else { |
| 37 | util.Warning("CakePHP: .env file exists already. Creating .env.ddev. You can rename it or copy settings to your .env file.") |
| 38 | } |
| 39 | } else { |
| 40 | util.Success("CakePHP: Creating .env file to store your config settings.") |
| 41 | } |
| 42 | err = fileutil.CopyFile(filepath.Join(app.AppRoot, app.ComposerRoot, "config/.env.example"), envFilePath) |
| 43 | if err != nil { |
| 44 | util.Debug("CakePHP: .env.example does not exist yet in config folder, not trying to process it") |
| 45 | return nil |
| 46 | } |
| 47 | _, envText, err := ReadProjectEnvFile(envFilePath) |
| 48 | if err != nil { |
| 49 | return err |
| 50 | } |
| 51 | port := "3306" |
| 52 | dbConnection := "mysql" |
| 53 | dbParams := "" |
| 54 | if app.Database.Type == nodeps.Postgres { |
| 55 | dbConnection = "postgres" |
| 56 | port = "5432" |
| 57 | dbParams = "?encoding=utf8" |
| 58 | } |
| 59 | envMap := map[string]string{ |
| 60 | "export APP_NAME": app.GetName(), |
| 61 | "export DEBUG": "true", |
| 62 | "export APP_ENCODING": "UTF-8", |
| 63 | "export DATABASE_URL": dbConnection + "://db:db@db:" + port + "/db" + dbParams, |
| 64 | "export EMAIL_TRANSPORT_DEFAULT_URL": "smtp://localhost:1025", |
| 65 | "export SECURITY_SALT": util.HashSalt(app.GetName()), |
| 66 | "export DEBUG_KIT_SAFE_TLD": "site", |
| 67 | "export APP_FULL_BASE_URL": app.GetPrimaryURL(), |
| 68 | } |
| 69 | err = WriteProjectEnvFile(envFilePath, envMap, envText) |
| 70 | if err != nil { |
| 71 | return err |
| 72 | } |
| 73 | err = enableDotEnvLoading(app) |
| 74 | if err != nil { |
| 75 | return err |
| 76 | } |
nothing calls this directly
no test coverage detected