Skip to content

Commit

Permalink
Process headers & rewrites for wsl:create-sites
Browse files Browse the repository at this point in the history
  • Loading branch information
svpernova09 committed Sep 11, 2021
1 parent a53dca9 commit 885da8b
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions src/WslCreateSiteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,37 @@ public function execute(InputInterface $input, OutputInterface $output)
foreach ($settings['wsl_sites'] as $key => $site) {
$type = $site['type'] ?? 'laravel';
$create_cmd = '';
$headers = false;
$rewrites = false;
// check & process headers
if(array_key_exists('headers', $site)){
foreach($site['headers'] as $header) {
$headers[$header['key']] = $header['value'];
}
}
// check & process rewrites
if(array_key_exists('rewrites', $site)){
foreach($site['rewrites'] as $rewrite) {
$rewrites[$rewrite['map']] = $rewrite['to'];
}
}

$args = [
$site['map'], // $1
$site['to'], // $2
$site['port'] ?? 80, // $3
$site['ssl'] ?? 443, // $4
$site['php'] ?? '7.4', // $5
'', // $6 params
$site['xhgui'] ?? '', // $7
$site['exec'] ?? false, // $8
'', // $9 headers
'', // $10 rewrites
$site['map'], // $0
$site['to'], // $1
$site['port'] ?? 80, // $2
$site['ssl'] ?? 443, // $3
$site['php'] ?? '8.0', // $4
'', // $5 params
$site['xhgui'] ?? '', // $6
$site['exec'] ?? false, // $7
$headers, // $8 headers
$rewrites, // $9 rewrites
];

$create_cmd = "sudo bash {$this->basePath}/scripts/site-types/{$type}.sh {$args[0]} \"{$args[1]}\"";
$create_cmd .= " {$args[2]} {$args[3]} {$args[4]} {$args[5]} {$args[6]} {$args[7]} {$args[8]} {$args[9]}";
$create_cmd .= " {$args[10]}";


// run command to create the site
$shell_output = shell_exec($create_cmd);
Expand Down

0 comments on commit 885da8b

Please sign in to comment.