Skip to content

Commit a59a462

Browse files
committed
Small changes to allow Valet to be used in non-CLI contexts
1 parent 2cead8d commit a59a462

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

cli/includes/compatibility.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
<?php
22

3+
if (php_sapi_name() !== "cli") {
4+
// Allow bypassing these checks if using Valet in a non-CLI app
5+
return;
6+
}
7+
38
/**
49
* Check the system's compatibility with Valet.
510
*/

cli/includes/helpers.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,22 @@
44

55
use Exception;
66
use Illuminate\Container\Container;
7-
use Symfony\Component\Process\Process;
8-
use Symfony\Component\Console\Output\ConsoleOutput;
97
use Symfony\Component\Console\Helper\Table;
8+
use Symfony\Component\Console\Output\ConsoleOutput;
109

1110
/**
12-
* Define the ~/.config/valet path as a constant.
11+
* Define constants
1312
*/
14-
define('VALET_LOOPBACK', '127.0.0.1');
15-
define('VALET_HOME_PATH', $_SERVER['HOME'].'/.config/valet');
16-
define('VALET_SERVER_PATH', realpath(__DIR__ . '/../../server.php'));
17-
define('VALET_STATIC_PREFIX', '41c270e4-5535-4daa-b23e-c269744c2f45');
13+
if (! defined('VALET_LOOPBACK')) {
14+
define('VALET_LOOPBACK', '127.0.0.1');
15+
define('VALET_HOME_PATH', $_SERVER['HOME'] . '/.config/valet');
16+
define('VALET_SERVER_PATH', realpath(__DIR__ . '/../../server.php'));
17+
define('VALET_STATIC_PREFIX', '41c270e4-5535-4daa-b23e-c269744c2f45');
1818

19-
define('VALET_LEGACY_HOME_PATH', $_SERVER['HOME'].'/.valet');
19+
define('VALET_LEGACY_HOME_PATH', $_SERVER['HOME'] . '/.valet');
2020

21-
define('BREW_PREFIX', (new CommandLine())->runAsUser('printf $(brew --prefix)'));
21+
define('BREW_PREFIX', (new CommandLine())->runAsUser('printf $(brew --prefix)'));
22+
}
2223

2324
/**
2425
* Output the given text to the console.
@@ -28,7 +29,7 @@
2829
*/
2930
function info($output)
3031
{
31-
output('<info>'.$output.'</info>');
32+
output('<info>' . $output . '</info>');
3233
}
3334

3435
/**
@@ -39,7 +40,7 @@ function info($output)
3940
*/
4041
function warning($output)
4142
{
42-
output('<fg=red>'.$output.'</>');
43+
output('<fg=red>' . $output . '</>');
4344
}
4445

4546
/**
@@ -70,7 +71,7 @@ function output($output)
7071
return;
7172
}
7273

73-
(new ConsoleOutput)->writeln($output);
74+
(new ConsoleOutput())->writeln($output);
7475
}
7576

7677
if (! function_exists('resolve')) {

0 commit comments

Comments
 (0)