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\FlightImporter;
|
||||
use App\Services\ImportExport\SubfleetImporter;
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use League\Csv\Exception;
|
||||
use League\Csv\Reader;
|
||||
use Log;
|
||||
use Validator;
|
||||
|
||||
/**
|
||||
* Class ImportService
|
||||
|
@ -20,6 +20,7 @@
|
||||
"appstract/laravel-opcache": "^2.0",
|
||||
"arrilot/laravel-widgets": "3.13.*",
|
||||
"doctrine/dbal": "2.9.*",
|
||||
"elcobvg/laravel-opcache": "0.4.*",
|
||||
"fzaninotto/faker": "^1.8",
|
||||
"guzzlehttp/guzzle": "6.3.*",
|
||||
"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",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "99c96d01e78e1d4400295a887ac36667",
|
||||
"content-hash": "cba2f67665d4583407a72462dab8bf60",
|
||||
"packages": [
|
||||
{
|
||||
"name": "akaunting/money",
|
||||
@ -1326,6 +1326,63 @@
|
||||
],
|
||||
"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",
|
||||
"version": "1.7.3",
|
||||
|
@ -24,7 +24,14 @@ return [
|
||||
],
|
||||
|
||||
'stores' => [
|
||||
'array' => ['driver' => 'array'],
|
||||
'apc' => [
|
||||
'driver' => 'apc',
|
||||
],
|
||||
|
||||
'array' => [
|
||||
'driver' => 'array',
|
||||
],
|
||||
|
||||
'database' => [
|
||||
'driver' => 'database',
|
||||
'table' => 'cache',
|
||||
@ -55,6 +62,10 @@ return [
|
||||
],
|
||||
],
|
||||
|
||||
'opcache' => [
|
||||
'driver' => 'opcache',
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => 'default',
|
||||
|
@ -5,6 +5,15 @@ return [
|
||||
'version' => '7.2'
|
||||
],
|
||||
|
||||
'cache' => [
|
||||
// Default driver to use when no driver is present
|
||||
'default' => 'file',
|
||||
'drivers' => [
|
||||
'Zend OPcache' => 'opcache',
|
||||
'apc' => 'apc',
|
||||
],
|
||||
],
|
||||
|
||||
'extensions' => [
|
||||
'calendar',
|
||||
'openssl',
|
||||
|
@ -4,6 +4,7 @@ namespace Modules\Installer\Http\Controllers;
|
||||
|
||||
use App\Contracts\Controller;
|
||||
use App\Services\Installer\MigrationService;
|
||||
use function count;
|
||||
use Illuminate\Http\Request;
|
||||
use Log;
|
||||
|
||||
@ -45,7 +46,7 @@ class UpdaterController extends Controller
|
||||
public function step1(Request $request)
|
||||
{
|
||||
$migrations = $this->migrationSvc->migrationsAvailable();
|
||||
if(\count($migrations) > 0) {
|
||||
if(count($migrations) > 0) {
|
||||
Log::info('No migrations found');
|
||||
}
|
||||
|
||||
@ -64,7 +65,7 @@ class UpdaterController extends Controller
|
||||
Log::info('Update: run_migrations', $request->post());
|
||||
|
||||
$migrations = $this->migrationSvc->migrationsAvailable();
|
||||
if(\count($migrations) === 0) {
|
||||
if(count($migrations) === 0) {
|
||||
$this->migrationSvc->syncAllSeeds();
|
||||
return view('installer::update/steps/step3-update-complete');
|
||||
}
|
||||
|
@ -3,8 +3,12 @@
|
||||
namespace Modules\Installer\Services;
|
||||
|
||||
use App\Contracts\Service;
|
||||
use Exception;
|
||||
use function extension_loaded;
|
||||
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 PDO;
|
||||
use Symfony\Component\HttpFoundation\File\Exception\FileException;
|
||||
@ -28,6 +32,7 @@ class ConfigService extends Service
|
||||
'APP_KEY' => $this->createAppKey(),
|
||||
'SITE_NAME' => '',
|
||||
'SITE_URL' => 'http://phpvms.test',
|
||||
'CACHE_PREFIX' => '',
|
||||
'DB_CONN' => '',
|
||||
'DB_HOST' => '',
|
||||
'DB_PORT' => 3306,
|
||||
@ -41,8 +46,8 @@ class ConfigService extends Service
|
||||
$opts = array_merge($opts, $attrs);
|
||||
|
||||
$opts = $this->determinePdoOptions($opts);
|
||||
$opts = $this->getCacheDriver($opts);
|
||||
$opts = $this->getQueueDriver($opts);
|
||||
$opts = $this->configCacheDriver($opts);
|
||||
$opts = $this->configQueueDriver($opts);
|
||||
|
||||
$this->writeConfigFiles($opts);
|
||||
|
||||
@ -64,7 +69,7 @@ class ConfigService extends Service
|
||||
$key = strtoupper($key);
|
||||
|
||||
# cast for any boolean values
|
||||
if(\is_bool($value)) {
|
||||
if(is_bool($value)) {
|
||||
$value = $value === true ? 'true' : 'false';
|
||||
}
|
||||
|
||||
@ -129,14 +134,23 @@ class ConfigService extends Service
|
||||
* @param $opts
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getCacheDriver($opts)
|
||||
protected function configCacheDriver($opts)
|
||||
{
|
||||
if(\extension_loaded('apc')) {
|
||||
$opts['CACHE_DRIVER'] = 'apc';
|
||||
} else {
|
||||
$opts['CACHE_DRIVER'] = 'array';
|
||||
// Set the cache prefix
|
||||
$opts['CACHE_PREFIX'] = $opts['SITE_NAME'].'_';
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
@ -146,7 +160,7 @@ class ConfigService extends Service
|
||||
* @param $opts
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getQueueDriver($opts)
|
||||
protected function configQueueDriver($opts)
|
||||
{
|
||||
# If we're setting up a database, then also setup
|
||||
# the default queue driver to use the database
|
||||
@ -164,13 +178,13 @@ class ConfigService extends Service
|
||||
*/
|
||||
public function removeConfigFiles()
|
||||
{
|
||||
$env_file = \App::environmentFilePath();
|
||||
$config_file = \App::environmentPath().'/config.php';
|
||||
$env_file = App::environmentFilePath();
|
||||
$config_file = App::environmentPath().'/config.php';
|
||||
|
||||
if (file_exists($env_file)) {
|
||||
try {
|
||||
unlink($env_file);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
}
|
||||
}
|
||||
@ -178,7 +192,7 @@ class ConfigService extends Service
|
||||
if(file_exists($config_file)) {
|
||||
try {
|
||||
unlink($config_file);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
}
|
||||
}
|
||||
@ -193,7 +207,7 @@ class ConfigService extends Service
|
||||
{
|
||||
Stub::setBasePath(resource_path('/stubs/installer'));
|
||||
|
||||
$env_file = \App::environmentFilePath();
|
||||
$env_file = App::environmentFilePath();
|
||||
|
||||
if(file_exists($env_file) && !is_writable($env_file)) {
|
||||
Log::error('Permissions on existing env.php is not writable');
|
||||
@ -206,8 +220,8 @@ class ConfigService extends Service
|
||||
try {
|
||||
$stub = new Stub('/env.stub', $opts);
|
||||
$stub->render();
|
||||
$stub->saveTo(\App::environmentPath(), \App::environmentFile());
|
||||
} catch(\Exception $e) {
|
||||
$stub->saveTo(App::environmentPath(), App::environmentFile());
|
||||
} catch(Exception $e) {
|
||||
throw new FileException('Couldn\'t write env.php. (' . $e . ')');
|
||||
}
|
||||
|
||||
@ -218,9 +232,9 @@ class ConfigService extends Service
|
||||
try {
|
||||
$stub = new Stub('/config.stub', $opts);
|
||||
$stub->render();
|
||||
$stub->saveTo(\App::environmentPath(), 'config.php');
|
||||
} catch (\Exception $e) {
|
||||
unlink(\App::environmentPath().'/'. \App::environmentFile());
|
||||
$stub->saveTo(App::environmentPath(), 'config.php');
|
||||
} catch (Exception $e) {
|
||||
unlink(App::environmentPath().'/'. App::environmentFile());
|
||||
throw new FileException('Couldn\'t write config.php. (' . $e . ')');
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
return [
|
||||
|
||||
# overrides app.php
|
||||
// Overrides config/app.php
|
||||
'app' => [
|
||||
'name' => '$SITE_NAME$',
|
||||
'url' => '$SITE_URL$',
|
||||
@ -17,7 +17,7 @@ return [
|
||||
'debug' => false,
|
||||
],
|
||||
|
||||
# overrides phpvms.php
|
||||
// Overrides config/phpvms.php
|
||||
'phpvms' => [
|
||||
/**
|
||||
* The ISO "Currency Code" to use, the list is in config/money.php
|
||||
@ -28,23 +28,25 @@ return [
|
||||
'currency' => 'USD',
|
||||
],
|
||||
|
||||
# This is the name of the active theme
|
||||
// This is the name of the active theme
|
||||
// Overrides config/themes.php
|
||||
'themes' => [
|
||||
'default' => 'default',
|
||||
],
|
||||
|
||||
// Overrides config/vacentral.php
|
||||
'vacentral' => [
|
||||
'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' => [
|
||||
'default' => '$CACHE_DRIVER$',
|
||||
'prefix' => 'phpvms_',
|
||||
'prefix' => '$CACHE_PREFIX$',
|
||||
],
|
||||
|
||||
/*
|
||||
@ -64,7 +66,7 @@ return [
|
||||
],
|
||||
],
|
||||
|
||||
# overrides database.php
|
||||
// Overrides config/database.php
|
||||
'database' => [
|
||||
'default' => env('DB_CONNECTION', '$DB_CONN$'),
|
||||
'connections' => [
|
||||
@ -79,6 +81,7 @@ return [
|
||||
],
|
||||
],
|
||||
|
||||
// Overrides config/logging.php
|
||||
'logging' => [
|
||||
'channels' => [
|
||||
'single' => ['level' => 'debug'],
|
||||
@ -86,7 +89,7 @@ return [
|
||||
],
|
||||
],
|
||||
|
||||
# overrides mail.php
|
||||
// Overrides config/mail.php
|
||||
'mail' => [
|
||||
'driver' => 'mail',
|
||||
'host' => '',
|
||||
@ -99,6 +102,7 @@ return [
|
||||
'password' => '',
|
||||
],
|
||||
|
||||
// Overrides config/session.php
|
||||
'session' => [
|
||||
'default' => 'file',
|
||||
'lifetime' => 60 * 24, # 24 hours
|
||||
|
Loading…
Reference in New Issue
Block a user