Add opcache option; change detection during install for cache driver
This commit is contained in:
parent
a0a6ab027f
commit
a9c5be1c70
@ -13,11 +13,11 @@ use App\Services\ImportExport\ExpenseImporter;
|
|||||||
use App\Services\ImportExport\FareImporter;
|
use App\Services\ImportExport\FareImporter;
|
||||||
use App\Services\ImportExport\FlightImporter;
|
use App\Services\ImportExport\FlightImporter;
|
||||||
use App\Services\ImportExport\SubfleetImporter;
|
use App\Services\ImportExport\SubfleetImporter;
|
||||||
|
use Illuminate\Contracts\Validation\Validator;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
use League\Csv\Exception;
|
use League\Csv\Exception;
|
||||||
use League\Csv\Reader;
|
use League\Csv\Reader;
|
||||||
use Log;
|
|
||||||
use Validator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ImportService
|
* Class ImportService
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
"appstract/laravel-opcache": "^2.0",
|
"appstract/laravel-opcache": "^2.0",
|
||||||
"arrilot/laravel-widgets": "3.13.*",
|
"arrilot/laravel-widgets": "3.13.*",
|
||||||
"doctrine/dbal": "2.9.*",
|
"doctrine/dbal": "2.9.*",
|
||||||
|
"elcobvg/laravel-opcache": "0.4.*",
|
||||||
"fzaninotto/faker": "^1.8",
|
"fzaninotto/faker": "^1.8",
|
||||||
"guzzlehttp/guzzle": "6.3.*",
|
"guzzlehttp/guzzle": "6.3.*",
|
||||||
"hashids/hashids": "2.0.*",
|
"hashids/hashids": "2.0.*",
|
||||||
|
59
composer.lock
generated
59
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "99c96d01e78e1d4400295a887ac36667",
|
"content-hash": "cba2f67665d4583407a72462dab8bf60",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "akaunting/money",
|
"name": "akaunting/money",
|
||||||
@ -1326,6 +1326,63 @@
|
|||||||
],
|
],
|
||||||
"time": "2019-06-23T10:14:27+00:00"
|
"time": "2019-06-23T10:14:27+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "elcobvg/laravel-opcache",
|
||||||
|
"version": "v0.4.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/elcobvg/laravel-opcache.git",
|
||||||
|
"reference": "2b559c22521a78b089f7121f01203e03be0ee987"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/elcobvg/laravel-opcache/zipball/2b559c22521a78b089f7121f01203e03be0ee987",
|
||||||
|
"reference": "2b559c22521a78b089f7121f01203e03be0ee987",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=7.0.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"mockery/mockery": "1.0",
|
||||||
|
"orchestra/testbench": "3.5",
|
||||||
|
"phpunit/phpunit": "6.5",
|
||||||
|
"squizlabs/php_codesniffer": "3.2"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"laravel": {
|
||||||
|
"providers": [
|
||||||
|
"ElcoBvg\\Opcache\\ServiceProvider"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"ElcoBvg\\Opcache\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Elco Brouwer von Gonzenbach",
|
||||||
|
"email": "elco.brouwer@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Custom OPcache Cache Driver for Laravel. Faster than Redis or memcached.",
|
||||||
|
"homepage": "https://github.com/elcobvg/laravel-opcache",
|
||||||
|
"keywords": [
|
||||||
|
"Opcache",
|
||||||
|
"cache",
|
||||||
|
"driver",
|
||||||
|
"laravel",
|
||||||
|
"webprofiler"
|
||||||
|
],
|
||||||
|
"time": "2018-10-08T04:02:08+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "erusev/parsedown",
|
"name": "erusev/parsedown",
|
||||||
"version": "1.7.3",
|
"version": "1.7.3",
|
||||||
|
@ -24,7 +24,14 @@ return [
|
|||||||
],
|
],
|
||||||
|
|
||||||
'stores' => [
|
'stores' => [
|
||||||
'array' => ['driver' => 'array'],
|
'apc' => [
|
||||||
|
'driver' => 'apc',
|
||||||
|
],
|
||||||
|
|
||||||
|
'array' => [
|
||||||
|
'driver' => 'array',
|
||||||
|
],
|
||||||
|
|
||||||
'database' => [
|
'database' => [
|
||||||
'driver' => 'database',
|
'driver' => 'database',
|
||||||
'table' => 'cache',
|
'table' => 'cache',
|
||||||
@ -55,6 +62,10 @@ return [
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'opcache' => [
|
||||||
|
'driver' => 'opcache',
|
||||||
|
],
|
||||||
|
|
||||||
'redis' => [
|
'redis' => [
|
||||||
'driver' => 'redis',
|
'driver' => 'redis',
|
||||||
'connection' => 'default',
|
'connection' => 'default',
|
||||||
|
@ -5,6 +5,15 @@ return [
|
|||||||
'version' => '7.2'
|
'version' => '7.2'
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'cache' => [
|
||||||
|
// Default driver to use when no driver is present
|
||||||
|
'default' => 'file',
|
||||||
|
'drivers' => [
|
||||||
|
'Zend OPcache' => 'opcache',
|
||||||
|
'apc' => 'apc',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
'extensions' => [
|
'extensions' => [
|
||||||
'calendar',
|
'calendar',
|
||||||
'openssl',
|
'openssl',
|
||||||
|
@ -4,6 +4,7 @@ namespace Modules\Installer\Http\Controllers;
|
|||||||
|
|
||||||
use App\Contracts\Controller;
|
use App\Contracts\Controller;
|
||||||
use App\Services\Installer\MigrationService;
|
use App\Services\Installer\MigrationService;
|
||||||
|
use function count;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
@ -45,7 +46,7 @@ class UpdaterController extends Controller
|
|||||||
public function step1(Request $request)
|
public function step1(Request $request)
|
||||||
{
|
{
|
||||||
$migrations = $this->migrationSvc->migrationsAvailable();
|
$migrations = $this->migrationSvc->migrationsAvailable();
|
||||||
if(\count($migrations) > 0) {
|
if(count($migrations) > 0) {
|
||||||
Log::info('No migrations found');
|
Log::info('No migrations found');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +65,7 @@ class UpdaterController extends Controller
|
|||||||
Log::info('Update: run_migrations', $request->post());
|
Log::info('Update: run_migrations', $request->post());
|
||||||
|
|
||||||
$migrations = $this->migrationSvc->migrationsAvailable();
|
$migrations = $this->migrationSvc->migrationsAvailable();
|
||||||
if(\count($migrations) === 0) {
|
if(count($migrations) === 0) {
|
||||||
$this->migrationSvc->syncAllSeeds();
|
$this->migrationSvc->syncAllSeeds();
|
||||||
return view('installer::update/steps/step3-update-complete');
|
return view('installer::update/steps/step3-update-complete');
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,12 @@
|
|||||||
namespace Modules\Installer\Services;
|
namespace Modules\Installer\Services;
|
||||||
|
|
||||||
use App\Contracts\Service;
|
use App\Contracts\Service;
|
||||||
|
use Exception;
|
||||||
|
use function extension_loaded;
|
||||||
use Illuminate\Encryption\Encrypter;
|
use Illuminate\Encryption\Encrypter;
|
||||||
use Log;
|
use Illuminate\Support\Facades\App;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use function is_bool;
|
||||||
use Nwidart\Modules\Support\Stub;
|
use Nwidart\Modules\Support\Stub;
|
||||||
use PDO;
|
use PDO;
|
||||||
use Symfony\Component\HttpFoundation\File\Exception\FileException;
|
use Symfony\Component\HttpFoundation\File\Exception\FileException;
|
||||||
@ -24,25 +28,26 @@ class ConfigService extends Service
|
|||||||
public function createConfigFiles($attrs): bool
|
public function createConfigFiles($attrs): bool
|
||||||
{
|
{
|
||||||
$opts = [
|
$opts = [
|
||||||
'APP_ENV' => 'dev',
|
'APP_ENV' => 'dev',
|
||||||
'APP_KEY' => $this->createAppKey(),
|
'APP_KEY' => $this->createAppKey(),
|
||||||
'SITE_NAME' => '',
|
'SITE_NAME' => '',
|
||||||
'SITE_URL' => 'http://phpvms.test',
|
'SITE_URL' => 'http://phpvms.test',
|
||||||
'DB_CONN' => '',
|
'CACHE_PREFIX' => '',
|
||||||
'DB_HOST' => '',
|
'DB_CONN' => '',
|
||||||
'DB_PORT' => 3306,
|
'DB_HOST' => '',
|
||||||
'DB_NAME' => '',
|
'DB_PORT' => 3306,
|
||||||
'DB_USER' => '',
|
'DB_NAME' => '',
|
||||||
'DB_PASS' => '',
|
'DB_USER' => '',
|
||||||
'DB_PREFIX' => '',
|
'DB_PASS' => '',
|
||||||
|
'DB_PREFIX' => '',
|
||||||
'DB_EMULATE_PREPARES' => false,
|
'DB_EMULATE_PREPARES' => false,
|
||||||
];
|
];
|
||||||
|
|
||||||
$opts = array_merge($opts, $attrs);
|
$opts = array_merge($opts, $attrs);
|
||||||
|
|
||||||
$opts = $this->determinePdoOptions($opts);
|
$opts = $this->determinePdoOptions($opts);
|
||||||
$opts = $this->getCacheDriver($opts);
|
$opts = $this->configCacheDriver($opts);
|
||||||
$opts = $this->getQueueDriver($opts);
|
$opts = $this->configQueueDriver($opts);
|
||||||
|
|
||||||
$this->writeConfigFiles($opts);
|
$this->writeConfigFiles($opts);
|
||||||
|
|
||||||
@ -64,7 +69,7 @@ class ConfigService extends Service
|
|||||||
$key = strtoupper($key);
|
$key = strtoupper($key);
|
||||||
|
|
||||||
# cast for any boolean values
|
# cast for any boolean values
|
||||||
if(\is_bool($value)) {
|
if(is_bool($value)) {
|
||||||
$value = $value === true ? 'true' : 'false';
|
$value = $value === true ? 'true' : 'false';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,14 +134,23 @@ class ConfigService extends Service
|
|||||||
* @param $opts
|
* @param $opts
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
protected function getCacheDriver($opts)
|
protected function configCacheDriver($opts)
|
||||||
{
|
{
|
||||||
if(\extension_loaded('apc')) {
|
// Set the cache prefix
|
||||||
$opts['CACHE_DRIVER'] = 'apc';
|
$opts['CACHE_PREFIX'] = $opts['SITE_NAME'].'_';
|
||||||
} else {
|
|
||||||
$opts['CACHE_DRIVER'] = 'array';
|
// Figure out what cache driver to initially use, depending on
|
||||||
|
// what is installed. It won't detect redis or anything, though
|
||||||
|
foreach (config('installer.cache.drivers') as $ext => $driver) {
|
||||||
|
if (extension_loaded($ext)) {
|
||||||
|
Log::info('Detected extension "'.$ext.'", setting driver to "'.$driver.'"');
|
||||||
|
$opts['CACHE_DRIVER'] = $driver;
|
||||||
|
return $opts;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log::info('No extension detected, using file cache');
|
||||||
|
$opts['CACHE_DRIVER'] = config('installer.cache.default');
|
||||||
return $opts;
|
return $opts;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +160,7 @@ class ConfigService extends Service
|
|||||||
* @param $opts
|
* @param $opts
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
protected function getQueueDriver($opts)
|
protected function configQueueDriver($opts)
|
||||||
{
|
{
|
||||||
# If we're setting up a database, then also setup
|
# If we're setting up a database, then also setup
|
||||||
# the default queue driver to use the database
|
# the default queue driver to use the database
|
||||||
@ -164,13 +178,13 @@ class ConfigService extends Service
|
|||||||
*/
|
*/
|
||||||
public function removeConfigFiles()
|
public function removeConfigFiles()
|
||||||
{
|
{
|
||||||
$env_file = \App::environmentFilePath();
|
$env_file = App::environmentFilePath();
|
||||||
$config_file = \App::environmentPath().'/config.php';
|
$config_file = App::environmentPath().'/config.php';
|
||||||
|
|
||||||
if (file_exists($env_file)) {
|
if (file_exists($env_file)) {
|
||||||
try {
|
try {
|
||||||
unlink($env_file);
|
unlink($env_file);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
Log::error($e->getMessage());
|
Log::error($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -178,7 +192,7 @@ class ConfigService extends Service
|
|||||||
if(file_exists($config_file)) {
|
if(file_exists($config_file)) {
|
||||||
try {
|
try {
|
||||||
unlink($config_file);
|
unlink($config_file);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
Log::error($e->getMessage());
|
Log::error($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -193,7 +207,7 @@ class ConfigService extends Service
|
|||||||
{
|
{
|
||||||
Stub::setBasePath(resource_path('/stubs/installer'));
|
Stub::setBasePath(resource_path('/stubs/installer'));
|
||||||
|
|
||||||
$env_file = \App::environmentFilePath();
|
$env_file = App::environmentFilePath();
|
||||||
|
|
||||||
if(file_exists($env_file) && !is_writable($env_file)) {
|
if(file_exists($env_file) && !is_writable($env_file)) {
|
||||||
Log::error('Permissions on existing env.php is not writable');
|
Log::error('Permissions on existing env.php is not writable');
|
||||||
@ -206,8 +220,8 @@ class ConfigService extends Service
|
|||||||
try {
|
try {
|
||||||
$stub = new Stub('/env.stub', $opts);
|
$stub = new Stub('/env.stub', $opts);
|
||||||
$stub->render();
|
$stub->render();
|
||||||
$stub->saveTo(\App::environmentPath(), \App::environmentFile());
|
$stub->saveTo(App::environmentPath(), App::environmentFile());
|
||||||
} catch(\Exception $e) {
|
} catch(Exception $e) {
|
||||||
throw new FileException('Couldn\'t write env.php. (' . $e . ')');
|
throw new FileException('Couldn\'t write env.php. (' . $e . ')');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,9 +232,9 @@ class ConfigService extends Service
|
|||||||
try {
|
try {
|
||||||
$stub = new Stub('/config.stub', $opts);
|
$stub = new Stub('/config.stub', $opts);
|
||||||
$stub->render();
|
$stub->render();
|
||||||
$stub->saveTo(\App::environmentPath(), 'config.php');
|
$stub->saveTo(App::environmentPath(), 'config.php');
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
unlink(\App::environmentPath().'/'. \App::environmentFile());
|
unlink(App::environmentPath().'/'. App::environmentFile());
|
||||||
throw new FileException('Couldn\'t write config.php. (' . $e . ')');
|
throw new FileException('Couldn\'t write config.php. (' . $e . ')');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,17 +7,17 @@
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
||||||
# overrides app.php
|
// Overrides config/app.php
|
||||||
'app' => [
|
'app' => [
|
||||||
'name' => '$SITE_NAME$',
|
'name' => '$SITE_NAME$',
|
||||||
'url' => '$SITE_URL$',
|
'url' => '$SITE_URL$',
|
||||||
|
|
||||||
# Don't forget to change these when live
|
# Don't forget to change these when live
|
||||||
'env' => 'local',
|
'env' => 'local',
|
||||||
'debug' => false,
|
'debug' => false,
|
||||||
],
|
],
|
||||||
|
|
||||||
# overrides phpvms.php
|
// Overrides config/phpvms.php
|
||||||
'phpvms' => [
|
'phpvms' => [
|
||||||
/**
|
/**
|
||||||
* The ISO "Currency Code" to use, the list is in config/money.php
|
* The ISO "Currency Code" to use, the list is in config/money.php
|
||||||
@ -28,23 +28,25 @@ return [
|
|||||||
'currency' => 'USD',
|
'currency' => 'USD',
|
||||||
],
|
],
|
||||||
|
|
||||||
# This is the name of the active theme
|
// This is the name of the active theme
|
||||||
|
// Overrides config/themes.php
|
||||||
'themes' => [
|
'themes' => [
|
||||||
'default' => 'default',
|
'default' => 'default',
|
||||||
],
|
],
|
||||||
|
|
||||||
|
// Overrides config/vacentral.php
|
||||||
'vacentral' => [
|
'vacentral' => [
|
||||||
'api_key' => '',
|
'api_key' => '',
|
||||||
],
|
],
|
||||||
|
|
||||||
#
|
//
|
||||||
# Other settings and configuration you might not need to modify
|
// Other settings and configuration you might not need to modify
|
||||||
#
|
//
|
||||||
|
|
||||||
# overrides cache.php
|
// Overrides config/cache.php
|
||||||
'cache' => [
|
'cache' => [
|
||||||
'default' => '$CACHE_DRIVER$',
|
'default' => '$CACHE_DRIVER$',
|
||||||
'prefix' => 'phpvms_',
|
'prefix' => '$CACHE_PREFIX$',
|
||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -55,7 +57,7 @@ return [
|
|||||||
'enabled' => false,
|
'enabled' => false,
|
||||||
|
|
||||||
'sitekey' => '',
|
'sitekey' => '',
|
||||||
'secret' => '',
|
'secret' => '',
|
||||||
|
|
||||||
# Attributes can be found here:
|
# Attributes can be found here:
|
||||||
# https://developers.google.com/recaptcha/docs/display#render_param
|
# https://developers.google.com/recaptcha/docs/display#render_param
|
||||||
@ -64,7 +66,7 @@ return [
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
# overrides database.php
|
// Overrides config/database.php
|
||||||
'database' => [
|
'database' => [
|
||||||
'default' => env('DB_CONNECTION', '$DB_CONN$'),
|
'default' => env('DB_CONNECTION', '$DB_CONN$'),
|
||||||
'connections' => [
|
'connections' => [
|
||||||
@ -79,6 +81,7 @@ return [
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
|
// Overrides config/logging.php
|
||||||
'logging' => [
|
'logging' => [
|
||||||
'channels' => [
|
'channels' => [
|
||||||
'single' => ['level' => 'debug'],
|
'single' => ['level' => 'debug'],
|
||||||
@ -86,7 +89,7 @@ return [
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
# overrides mail.php
|
// Overrides config/mail.php
|
||||||
'mail' => [
|
'mail' => [
|
||||||
'driver' => 'mail',
|
'driver' => 'mail',
|
||||||
'host' => '',
|
'host' => '',
|
||||||
@ -99,6 +102,7 @@ return [
|
|||||||
'password' => '',
|
'password' => '',
|
||||||
],
|
],
|
||||||
|
|
||||||
|
// Overrides config/session.php
|
||||||
'session' => [
|
'session' => [
|
||||||
'default' => 'file',
|
'default' => 'file',
|
||||||
'lifetime' => 60 * 24, # 24 hours
|
'lifetime' => 60 * 24, # 24 hours
|
||||||
|
Loading…
Reference in New Issue
Block a user