Use .stub file to write the env.php file #157

This commit is contained in:
Nabeel Shahzad 2018-01-28 18:50:43 -06:00
parent 5cf79454b0
commit 1020b28977
3 changed files with 12 additions and 48 deletions

View File

@ -4,6 +4,7 @@ namespace Modules\Installer\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Database\Eloquent\Factory;
use Nwidart\Modules\Support\Stub;
use Route;

View File

@ -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 !!}

View File

@ -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);*/
}
}