#!/usr/bin/env php $val) { $envContent = preg_replace("/^" . $key . "\s*=\s*(.*?)$/m", $key . "=" . $val, $envContent); } file_put_contents($envPath, $envContent); return true; } function modifyMode($type) { $filePath = realpath(__DIR__ . '/../') . DIRECTORY_SEPARATOR . '/docker/php/php.conf'; if (!file_exists($filePath)) { return false; } $envContent = file_get_contents($filePath); $envContent = str_replace("#command=php bin/laravels start -i", "command=php bin/laravels start -i", $envContent); $envContent = str_replace("#command=./bin/inotify ./app", "command=./bin/inotify ./app", $envContent); if ($type == "dev") { $envContent = str_replace("command=php bin/laravels start -i", "#command=php bin/laravels start -i", $envContent); $this->modifyEnv([ 'APP_DEBUG' => 'true' ]); } else { $envContent = str_replace("command=./bin/inotify ./app", "#command=./bin/inotify ./app", $envContent); $this->modifyEnv([ 'APP_DEBUG' => 'false' ]); } file_put_contents($filePath, $envContent); return true; } } $array = getopt('', ['port:', 'ssl:', 'mode:']); $loader = new runLoader(); if (isset($array['mode'])) { $loader->modifyMode($array['mode']); } $data = []; if (isset($array['port'])) { $data['APP_PORT'] = $array['port']; } if (isset($array['ssl'])) { $data['APP_PORT_SSL'] = $array['ssl']; } if ($data) { $loader->modifyEnv($data); }