Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: spark config:check detects Config Caching #8711

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Loading