Skip to content
Snippets Groups Projects
Select Git revision
  • 2559ae33b495ab7ff08611fc706d416a2ea7511a
  • main default protected
  • register-logging-channel
  • expr-lang
  • ci-82
  • attr-events
  • locale-wip
  • custom-routes
  • v0.1.85
  • v0.1.84
  • v0.1.83
  • v0.1.82
  • v0.1.81
  • v0.1.80
  • v0.1.79
  • v0.1.78
  • v0.1.77
  • v0.1.76
  • v0.1.75
  • v0.1.74
  • v0.1.73
  • v0.1.72
  • v0.1.71
  • v0.1.70
  • v0.1.69
  • v0.1.68
  • v0.1.67
  • v0.1.65
28 results

disable-database-url.php

  • disable-database-url.php 899 B
    #!/usr/bin/env php
    <?php
    
    //########################################################################################################
    // Disables the DATABASE_URL env variable in `.env` when its default value is used to prevent confusion.
    //########################################################################################################
    
    // read the entire string
    $str = file_get_contents('.env');
    
    $pattern = '/^(DATABASE_URL=\"postgresql:\/\/symfony:ChangeMe@127.0.0.1:5432\/app)/im';
    $replacement = '# $1';
    
    $strAfter = preg_replace($pattern, $replacement, $str);
    
    if ($strAfter !== $str) {
        // write the entire string
        file_put_contents('.env', $strAfter);
    
        // move config/packages/doctrine.yaml so nothing depends on DATABASE_URL
        if (is_file('config/packages/doctrine.yaml')) {
            rename('config/packages/doctrine.yaml', 'config/packages/doctrine.yaml.bak');
        }
    }