New_Micro_Learning/scripts/configure-project-php.ps1

18 خطوط
873 B
PowerShell

$ErrorActionPreference = 'Stop'
$projectRoot = Split-Path -Parent $PSScriptRoot
$phpConfigDirectory = Join-Path $projectRoot 'backend'
$environmentFile = Join-Path $phpConfigDirectory '.env'
$testingEnvironmentFile = Join-Path $phpConfigDirectory '.env.testing'
[Environment]::SetEnvironmentVariable('PHPRC', $phpConfigDirectory, 'User')
$env:PHPRC = $phpConfigDirectory
$testingEnvironment = [IO.File]::ReadAllText($environmentFile)
$testingEnvironment = [Regex]::Replace($testingEnvironment, '(?m)^APP_ENV=.*$', 'APP_ENV=testing')
$testingEnvironment = [Regex]::Replace($testingEnvironment, '(?m)^APP_DEBUG=.*$', 'APP_DEBUG=false')
$testingEnvironment = [Regex]::Replace($testingEnvironment, '(?m)^DB_DATABASE=.*$', 'DB_DATABASE=microlearn_test')
[IO.File]::WriteAllText($testingEnvironmentFile, $testingEnvironment, [Text.UTF8Encoding]::new($false))
php --ini
php -m