Skip to content

Commit

Permalink
Merge pull request #8711 from kenjis/feat-config-check-shows-config-c…
Browse files Browse the repository at this point in the history
…ache

feat: `spark config:check` detects Config Caching
  • Loading branch information
kenjis authored Apr 5, 2024
2 parents c3817a6 + 6b80f3d commit 0cab3e5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
14 changes: 14 additions & 0 deletions system/Commands/Utilities/ConfigCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@

namespace CodeIgniter\Commands\Utilities;

use CodeIgniter\Cache\FactoriesCache;
use CodeIgniter\CLI\BaseCommand;
use CodeIgniter\CLI\CLI;
use CodeIgniter\Config\BaseConfig;
use Config\Optimize;
use Kint\Kint;

/**
Expand Down Expand Up @@ -87,6 +89,14 @@ public function run(array $params)
/** @var class-string<BaseConfig> $class */
$class = $params[0];

// Load Config cache if it is enabled.
$configCacheEnabled = class_exists(Optimize::class)
&& (new Optimize())->configCacheEnabled;
if ($configCacheEnabled) {
$factoriesCache = new FactoriesCache();
$factoriesCache->load('config');
}

$config = config($class);

if ($config === null) {
Expand All @@ -103,6 +113,10 @@ public function run(array $params)
);
}

CLI::newLine();
$state = CLI::color($configCacheEnabled ? 'Enabled' : 'Disabled', 'green');
CLI::write('Config Caching: ' . $state);

return EXIT_SUCCESS;
}

Expand Down
11 changes: 9 additions & 2 deletions user_guide_src/source/general/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -378,10 +378,11 @@ Confirming Config Values
************************

The actual Config object property values are changed at runtime by the :ref:`registrars`
and :ref:`Environment Variables <configuration-classes-and-environment-variables>`.
and :ref:`Environment Variables <configuration-classes-and-environment-variables>`,
and :ref:`factories-config-caching`.

CodeIgniter has the following :doc:`command <../cli/spark_commands>` to check
Config values.
the actual Config values.

.. _spark-config-check:

Expand Down Expand Up @@ -417,3 +418,9 @@ The output is like the following:
public 'CSPEnabled' -> boolean false
)
Config Caching: Disabled
You can see if Config Caching is eabled or not.

.. note:: If Config Caching is enabled, the cached values are used permanently.
See :ref:`factories-config-caching` for details.

0 comments on commit 0cab3e5

Please sign in to comment.