Set some defaults for the cache and queue drivers in the installer
This commit is contained in:
@@ -2,19 +2,7 @@ APP_ENV=dev
|
|||||||
APP_KEY=base64:ve66Z5Kt/zTN3p++0zOPu854PHfZkwJE5VuoFAlzHtI=
|
APP_KEY=base64:ve66Z5Kt/zTN3p++0zOPu854PHfZkwJE5VuoFAlzHtI=
|
||||||
APP_DEBUG=true
|
APP_DEBUG=true
|
||||||
APP_LOCALE=en
|
APP_LOCALE=en
|
||||||
APP_URL=http://localhost
|
|
||||||
|
|
||||||
APP_LOG=daily
|
APP_LOG=daily
|
||||||
APP_LOG_LEVEL=debug
|
APP_LOG_LEVEL=debug
|
||||||
APP_LOG_MAX_FILES=7
|
APP_LOG_MAX_FILES=7
|
||||||
|
|
||||||
DB_CONNECTION=sqlite
|
|
||||||
DB_HOST=
|
|
||||||
DB_PORT=
|
|
||||||
DB_DATABASE=
|
|
||||||
DB_USERNAME=
|
|
||||||
DB_PASSWORD=
|
|
||||||
DB_PREFIX=
|
|
||||||
|
|
||||||
CACHE_DRIVER=array
|
|
||||||
CACHE_PREFIX=
|
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class CreateJobsTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('jobs', function (Blueprint $table) {
|
||||||
|
$table->bigIncrements('id');
|
||||||
|
$table->string('queue')->index();
|
||||||
|
$table->longText('payload');
|
||||||
|
$table->unsignedTinyInteger('attempts');
|
||||||
|
$table->unsignedInteger('reserved_at')->nullable();
|
||||||
|
$table->unsignedInteger('available_at');
|
||||||
|
$table->unsignedInteger('created_at');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('jobs');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class CreateFailedJobsTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||||
|
$table->bigIncrements('id');
|
||||||
|
$table->text('connection');
|
||||||
|
$table->text('queue');
|
||||||
|
$table->longText('payload');
|
||||||
|
$table->longText('exception');
|
||||||
|
$table->timestamp('failed_at')->useCurrent();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('failed_jobs');
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -6,7 +6,7 @@ return [
|
|||||||
'env' => env('APP_ENV', 'dev'),
|
'env' => env('APP_ENV', 'dev'),
|
||||||
'debug' => env('APP_DEBUG', true),
|
'debug' => env('APP_DEBUG', true),
|
||||||
'url' => env('APP_URL', 'http://localhost'),
|
'url' => env('APP_URL', 'http://localhost'),
|
||||||
'version' => '4.0',
|
'version' => '7.0',
|
||||||
|
|
||||||
'timezone' => 'UTC',
|
'timezone' => 'UTC',
|
||||||
'locale' => env('APP_LOCALE', 'en'),
|
'locale' => env('APP_LOCALE', 'en'),
|
||||||
|
|||||||
+2
-2
@@ -56,8 +56,8 @@ return [
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
'from' => [
|
'from' => [
|
||||||
'address' => 'hello@example.com',
|
'name' => env('MAIL_FROM_NAME', 'phpVMS Admin'),
|
||||||
'name' => 'Example',
|
'address' => env('MAIL_FROM_ADDRESS', ''),
|
||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
+2
-2
@@ -14,12 +14,12 @@ return [
|
|||||||
/**
|
/**
|
||||||
* The skin to use for the front-end
|
* The skin to use for the front-end
|
||||||
*/
|
*/
|
||||||
'skin' => 'default',
|
'skin' => env('APP_SKIN', 'default'),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Your vaCentral API key
|
* Your vaCentral API key
|
||||||
*/
|
*/
|
||||||
'vacentral_api_key' => '',
|
'vacentral_api_key' => env('VACENTRAL_API_KEY', ''),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* vaCentral API URL. You likely don't need to change this
|
* vaCentral API URL. You likely don't need to change this
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ return [
|
|||||||
'queue' => 'default',
|
'queue' => 'default',
|
||||||
'retry_after' => 90,
|
'retry_after' => 90,
|
||||||
],
|
],
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -6,6 +6,10 @@ return [
|
|||||||
'php' => [
|
'php' => [
|
||||||
'version' => '7.0.0'
|
'version' => '7.0.0'
|
||||||
],
|
],
|
||||||
|
|
||||||
|
# TODO: Remove eventually
|
||||||
|
'env_postfix' => '.generated',
|
||||||
|
|
||||||
'extensions' => [
|
'extensions' => [
|
||||||
'openssl',
|
'openssl',
|
||||||
'pdo',
|
'pdo',
|
||||||
|
|||||||
@@ -4,7 +4,10 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
APP_ENV=dev
|
APP_ENV=dev
|
||||||
APP_KEY=base64:{!! $app_key !!}
|
APP_URL=http://localhost
|
||||||
|
APP_SKIN=default
|
||||||
|
VACENTRAL_API_KEY=
|
||||||
|
APP_KEY=base64:{!! $APP_KEY !!}
|
||||||
APP_DEBUG=true
|
APP_DEBUG=true
|
||||||
APP_LOCALE=en
|
APP_LOCALE=en
|
||||||
|
|
||||||
@@ -12,18 +15,25 @@ APP_LOG=daily
|
|||||||
APP_LOG_LEVEL=debug
|
APP_LOG_LEVEL=debug
|
||||||
APP_LOG_MAX_FILES=3
|
APP_LOG_MAX_FILES=3
|
||||||
|
|
||||||
APP_URL=http://localhost
|
DB_CONNECTION={!! $DB_CONN !!}
|
||||||
|
DB_HOST={!! $DB_HOST !!}
|
||||||
DB_CONNECTION={!! $db_conn !!}
|
DB_PORT={!! $DB_PORT !!}
|
||||||
DB_HOST={!! $db_host !!}
|
DB_DATABASE={!! $DB_NAME !!}
|
||||||
DB_PORT={!! $db_port !!}
|
DB_USERNAME={!! $DB_USER !!}
|
||||||
DB_DATABASE={!! $db_name !!}
|
DB_PASSWORD={!! $DB_PASS !!}
|
||||||
DB_USERNAME={!! $db_user !!}
|
|
||||||
DB_PASSWORD={!! $db_pass !!}
|
|
||||||
DB_PREFIX=
|
DB_PREFIX=
|
||||||
|
|
||||||
CACHE_DRIVER=array
|
MAIL_DRIVER=smtp
|
||||||
CACHE_PREFIX=
|
MAIL_FROM_ADDRESS=no-reply@phpvms.net
|
||||||
|
MAIL_FROM_NAME=phpVMS Admin
|
||||||
|
MAIL_HOST=smtp.mailgun.org
|
||||||
|
MAIL_PORT=587
|
||||||
|
MAIL_ENCRYPTION=tls
|
||||||
|
MAIL_USERNAME=
|
||||||
|
MAIL_PASSWORD=
|
||||||
|
|
||||||
|
CACHE_DRIVER={!! $CACHE_DRIVER !!}
|
||||||
|
CACHE_PREFIX=phpvms
|
||||||
|
|
||||||
REDIS_HOST=localhost
|
REDIS_HOST=localhost
|
||||||
REDIS_PASSWORD=
|
REDIS_PASSWORD=
|
||||||
@@ -31,4 +41,4 @@ REDIS_PORT=6379
|
|||||||
REDIS_DATABASE=1
|
REDIS_DATABASE=1
|
||||||
|
|
||||||
SESSION_DRIVER=array
|
SESSION_DRIVER=array
|
||||||
QUEUE_DRIVER=sync
|
QUEUE_DRIVER={!! $QUEUE_DRIVER !!}
|
||||||
|
|||||||
@@ -4,49 +4,93 @@ namespace Modules\Installer\Services;
|
|||||||
|
|
||||||
use Illuminate\Encryption\Encrypter;
|
use Illuminate\Encryption\Encrypter;
|
||||||
use Log;
|
use Log;
|
||||||
use PDO;
|
|
||||||
|
|
||||||
class EnvironmentService
|
class EnvironmentService
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check the PHP version that it meets the minimum requirement
|
* Create the .env file
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function createEnvFile($type, $host, $port, $name, $user, $pass)
|
public function createEnvFile($type, $host, $port, $name, $user, $pass)
|
||||||
{
|
{
|
||||||
$env_opts = [
|
$opts = [
|
||||||
'db_conn' => $type,
|
'APP_KEY' => $this->createAppKey(),
|
||||||
'db_host' => $host,
|
'DB_CONN' => $type,
|
||||||
'db_port' => $port,
|
'DB_HOST' => $host,
|
||||||
'db_name' => $name,
|
'DB_PORT' => $port,
|
||||||
'db_user' => $user,
|
'DB_NAME' => $name,
|
||||||
'db_pass' => $pass,
|
'DB_USER' => $user,
|
||||||
|
'DB_PASS' => $pass,
|
||||||
];
|
];
|
||||||
|
|
||||||
$env_opts['app_key'] = base64_encode(Encrypter::generateKey(config('app.cipher')));
|
$opts = $this->getCacheDriver($opts);
|
||||||
|
$opts = $this->getQueueDriver($opts);
|
||||||
|
|
||||||
|
$this->writeEnvFile($opts);
|
||||||
|
|
||||||
$this->writeEnvFile($env_opts);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the template file name and write it out
|
* Generate a fresh new APP_KEY
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function writeEnvFile($env_opts)
|
protected function createAppKey()
|
||||||
|
{
|
||||||
|
return base64_encode(Encrypter::generateKey(config('app.cipher')));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine is APC is installed, if so, then use it as a cache driver
|
||||||
|
* @param $opts
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
protected function getCacheDriver($opts)
|
||||||
|
{
|
||||||
|
if(\extension_loaded('apc')) {
|
||||||
|
$opts['CACHE_DRIVER'] = 'apc';
|
||||||
|
} else {
|
||||||
|
$opts['CACHE_DRIVER'] = 'filesystem';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $opts;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup a queue driver that's not the default "sync"
|
||||||
|
* driver, if a database is being used
|
||||||
|
* @param $opts
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
protected function getQueueDriver($opts)
|
||||||
|
{
|
||||||
|
# If we're setting up a database, then also setup
|
||||||
|
# the default queue driver to use the database
|
||||||
|
if ($opts['DB_CONN'] === 'mysql' || $opts['DB_CONN'] === 'postgres') {
|
||||||
|
$opts['QUEUE_DRIVER'] = 'database';
|
||||||
|
} else {
|
||||||
|
$opts['QUEUE_DRIVER'] = 'sync';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $opts;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the template file name and write it out
|
||||||
|
* @param $opts
|
||||||
|
*/
|
||||||
|
protected function writeEnvFile($opts)
|
||||||
{
|
{
|
||||||
$app = app();
|
$app = app();
|
||||||
$env_file = $app->environmentFilePath();
|
$env_file = $app->environmentFilePath();
|
||||||
|
$env_file .= config('installer.env_postfix');
|
||||||
|
|
||||||
# TODO: Remove this post-testing
|
# render it within Blade and log the contents
|
||||||
$env_file .= '.generated';
|
$env_contents = view('installer::stubs/env', $opts);
|
||||||
|
|
||||||
$env_contents = view('installer::stubs/env', $env_opts);
|
|
||||||
Log::info($env_contents);
|
Log::info($env_contents);
|
||||||
|
|
||||||
$fp = fopen($env_file, 'w');
|
$fp = fopen($env_file, 'w');
|
||||||
fwrite($fp, $env_contents);
|
fwrite($fp, $env_contents);
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user