Skip to content
This repository was archived by the owner on Oct 26, 2019. It is now read-only.

Commit

Permalink
Optimized settings
Browse files Browse the repository at this point in the history
  • Loading branch information
odan committed Jun 5, 2017
1 parent 984eb34 commit 6090d46
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 26 deletions.
4 changes: 2 additions & 2 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
}

if (isset($environment['env'])) {
$config = array_merge_recursive($config, read(__DIR__ . '/' . $environment['env'] . '.php'));
$config = array_replace_recursive($config, read(__DIR__ . '/' . $environment['env'] . '.php'));
}

if ($environment) {
$config = array_merge_recursive($config, $environment);
$config = array_replace_recursive($config, $environment);
}

return $config;
44 changes: 28 additions & 16 deletions config/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,42 @@

// Slim Settings
$config['displayErrorDetails'] = false;
$config['determineRouteBeforeAppMiddleware'] = true;
$config['determineRouteBeforeAppMiddleware'] = false;

// Path
$root = dirname(__DIR__);
$config['root_path'] = $root;
$config['tmp_path'] = $root . '/tmp';
$config['log_path'] = $root . '/tmp/log';
$config['cache_path'] = $root . '/tmp/cache';
$config['public_path'] = $root . '/public';
$config['locale_path'] = $root . '/resources/locale';
$config['migration_path'] = $root . '/resources/migrations';
$config['root'] = dirname(__DIR__);
$config['temp'] = $config['root'] . '/tmp';
$config['public'] = $config['root'] . '/public';

// Application token
$config['app_secret'] = '6c6bee844f2420ede093af25b58bb8ba8b7dc04d';
$config['app'] = [
'secret' => $config['root'] . '{{app_secret}}'
];

// Monolog settings
// Logger settings
$config['logger'] = [
'name' => 'app',
'path' => __DIR__ . '/../log/app.log',
'path' => $config['temp'] . '/log/app.log',
'level' => \Monolog\Logger::ERROR
];

// Cache settings
$config['cache'] = [
'path' => $config['root'] . '/tmp/cache'
];

// View settings
$config['view'] = [
'path' => $root . '/src/View'
'path' => $config['root'] . '/src/View'
];

// Assets
$config['assets'] = [
'path' => $root . '/public',
'path' => $config['public'],
// Internal cache adapter
'cache' => new \Symfony\Component\Cache\Adapter\FilesystemAdapter('assets-cache', 0, $root . '/tmp/cache'),
'cache' => new \Symfony\Component\Cache\Adapter\FilesystemAdapter('assets-cache', 0, $config['temp']),
// Public assets cache directory
'public_dir' => $root . '/public/cache',
'public_dir' => $config['public'] . '/cache',
// Enable JavaScript and CSS compression
'minify' => 1
];
Expand All @@ -58,6 +60,16 @@
'cache_expire' => 0
];

// Locale settings
$config['locale'] = [
'path' => $config['root'] . '/resources/locale'
];

// Database migration settings
$config['migration'] = [
'path' => $config['root'] . '/resources/migrations'
];

// Database
$config['db'] = array(
'driver' => 'mysql',
Expand Down
10 changes: 5 additions & 5 deletions config/dependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
$container = app()->getContainer();

// -----------------------------------------------------------------------------
// Service providers
// Service factories
// -----------------------------------------------------------------------------
// Twig
$container['view'] = function (Container $container) {
$settings = $container->get('settings');
$engine = new League\Plates\Engine($settings['view']['path'], null);
Expand All @@ -23,9 +22,6 @@
return $engine;
};

// -----------------------------------------------------------------------------
// Service factories
// -----------------------------------------------------------------------------
$container['logger'] = function (Container $container) {
$settings = $container->get('settings');
$logger = new Monolog\Logger($settings['logger']['name']);
Expand Down Expand Up @@ -66,3 +62,7 @@
$user = new \App\Service\User\UserSession($session, $db, $secret);
return $user;
};

// -----------------------------------------------------------------------------
// Action factories
// -----------------------------------------------------------------------------
2 changes: 1 addition & 1 deletion config/development.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
$config['assets']['minify'] = 0;

// Database
$config['db']['database'] = 'prisma';
$config['db']['database'] = '{{db_database}}';

return $config;
1 change: 1 addition & 0 deletions config/env.example.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* a security breach, and production values will never have to be
* shared with all project collaborators.
*/

// Error reporting
error_reporting(E_ALL);
ini_set('display_errors', '1');
Expand Down
2 changes: 1 addition & 1 deletion config/phinx.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

return array(
'paths' => [
'migrations' => settings()->get('migration_path')
'migrations' => settings()->get('migration')['path']
],
'environments' => [
'default_migration_table' => "phinxlog",
Expand Down
2 changes: 1 addition & 1 deletion config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function __($message)
function set_locale($locale = 'en_US', $domain = 'messages')
{
$settings = container()->get('settings');
$moFile = sprintf('%s/%s_%s.mo', $settings['locale_path'], $locale, $domain);
$moFile = sprintf('%s/%s_%s.mo', $settings['locale']['path'], $locale, $domain);

$translator = new Translator($locale, new MessageSelector());
$translator->addLoader('mo', new MoFileLoader());
Expand Down

0 comments on commit 6090d46

Please sign in to comment.