From 1020b2897762dad6e22905c57279304555e9cd93 Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Sun, 28 Jan 2018 18:50:43 -0600 Subject: [PATCH] Use .stub file to write the env.php file #157 --- .../Providers/InstallerServiceProvider.php | 1 + .../Resources/views/stubs/env.blade.php | 46 ------------------- .../Installer/Services/EnvironmentService.php | 13 +++++- 3 files changed, 12 insertions(+), 48 deletions(-) delete mode 100644 modules/Installer/Resources/views/stubs/env.blade.php diff --git a/modules/Installer/Providers/InstallerServiceProvider.php b/modules/Installer/Providers/InstallerServiceProvider.php index 2193c0ba..ff7d09e1 100644 --- a/modules/Installer/Providers/InstallerServiceProvider.php +++ b/modules/Installer/Providers/InstallerServiceProvider.php @@ -4,6 +4,7 @@ namespace Modules\Installer\Providers; use Illuminate\Support\ServiceProvider; use Illuminate\Database\Eloquent\Factory; +use Nwidart\Modules\Support\Stub; use Route; diff --git a/modules/Installer/Resources/views/stubs/env.blade.php b/modules/Installer/Resources/views/stubs/env.blade.php deleted file mode 100644 index f1687e5d..00000000 --- a/modules/Installer/Resources/views/stubs/env.blade.php +++ /dev/null @@ -1,46 +0,0 @@ -# -# Before you go live, remember to change the APP_ENV to production -# and APP_DEBUG to false. Adjust logging to taste -# - -APP_ENV={!! $APP_ENV !!} -APP_URL=http://localhost -APP_SKIN=default -APP_KEY=base64:{!! $APP_KEY !!} -APP_DEBUG=true -APP_LOCALE=en -APP_ANALYTICS_DISABLED=false - -PHPVMS_INSTALLED=true -PHPVMS_VA_NAME="phpvms" -VACENTRAL_API_KEY= -CHECKWX_API_KEY= - -APP_LOG=daily -APP_LOG_LEVEL=debug -APP_LOG_MAX_FILES=3 - -DB_CONNECTION={!! $DB_CONN !!} -DB_HOST={!! $DB_HOST !!} -DB_PORT={!! $DB_PORT !!} -DB_DATABASE={!! $DB_NAME !!} -DB_USERNAME={!! $DB_USER !!} -DB_PASSWORD={!! $DB_PASS !!} -DB_EMULATE_PREPARES={!! $DB_EMULATE_PREPARES !!} -DB_PREFIX= - -MAIL_DRIVER=smtp -MAIL_FROM_ADDRESS=no-reply@phpvms.net -MAIL_FROM_NAME="phpVMS Admin" -MAIL_HOST= -MAIL_PORT= -MAIL_ENCRYPTION= -MAIL_USERNAME= -MAIL_PASSWORD= - -CACHE_ENABLED=false -CACHE_DRIVER={!! $CACHE_DRIVER !!} -CACHE_PREFIX=phpvms - -SESSION_DRIVER=file -QUEUE_DRIVER={!! $QUEUE_DRIVER !!} diff --git a/modules/Installer/Services/EnvironmentService.php b/modules/Installer/Services/EnvironmentService.php index 0f459c66..b6071d9c 100644 --- a/modules/Installer/Services/EnvironmentService.php +++ b/modules/Installer/Services/EnvironmentService.php @@ -4,6 +4,7 @@ namespace Modules\Installer\Services; use Log; use PDO; +use Nwidart\Modules\Support\Stub; use Illuminate\Encryption\Encrypter; use Symfony\Component\HttpFoundation\File\Exception\FileException; @@ -171,7 +172,15 @@ class EnvironmentService throw new FileException('Can\'t write to the env.php file! Check the permissions'); } - $fp = fopen($env_file, 'wb'); + try { + $stub = new Stub('/env.stub', $opts); + $stub->render(); + $stub->saveTo(\App::environmentPath(), \App::environmentFile()); + } catch(\Exception $e) { + throw new FileException('Couldn\'t write the env.php. (' . $e . ')'); + } + + /*$fp = fopen($env_file, 'wb'); if($fp === false) { throw new FileException('Couldn\'t write the env.php. (' . error_get_last() .')'); } @@ -184,6 +193,6 @@ class EnvironmentService .$env_contents; fwrite($fp, $env_contents); - fclose($fp); + fclose($fp);*/ } }