This commit is contained in:
Sieciech 2021-08-07 11:17:47 +02:00
parent 69a6029555
commit 31d2446b03
1 changed files with 7 additions and 0 deletions

View File

@ -10,6 +10,7 @@ class PutEnv {
public function __construct() { public function __construct() {
$argv = $_SERVER['argv']; $argv = $_SERVER['argv'];
$argc = sizeof($argv); $argc = sizeof($argv);
print_r([$argc, $argv]);
switch($argc) { switch($argc) {
case 3: case 3:
$this->file = $argv[1]; $this->file = $argv[1];
@ -22,6 +23,12 @@ class PutEnv {
$this->key = $argv[2]; $this->key = $argv[2];
$this->value = fgets(STDIN); $this->value = fgets(STDIN);
break; break;
default:
echo "usage:
php8.0 putenv.php filename key value
echo value | php8.0 putenv filename key";
throw new Exception("invalid params");
} }
if (!file_exists($this->file)) { if (!file_exists($this->file)) {
throw new Exception('File not found'); throw new Exception('File not found');