# Settings System

Chamilo's configuration is managed through a set of settings schemas (around 40 of them, varying between releases) that define every configurable aspect of the platform. They live in `src/CoreBundle/Settings/` — the exact list there is the source of truth.

## How It Works

Settings are:

1. **Defined** in schema classes (`src/CoreBundle/Settings/*SettingsSchema.php`)
2. **Stored** in the database (`settings_current` table)
3. **Accessed** via the `SettingsManager` service
4. **Managed** through the administration web interface

## Settings Schemas

Each schema file defines a category of settings. Key schemas:

| Schema                       | Purpose                                                     |
| ---------------------------- | ----------------------------------------------------------- |
| `PlatformSettingsSchema`     | Institution info, timezone, server type, portal features    |
| `SecuritySettingsSchema`     | Login attempts, CAPTCHA, password policy, HTTP headers, 2FA |
| `RegistrationSettingsSchema` | Self-registration, required fields, auto-subscribe          |
| `CourseSettingsSchema`       | Course creation defaults, tools, catalog                    |
| `SessionSettingsSchema`      | Session defaults, visibility                                |
| `MailSettingsSchema`         | Email configuration, DKIM, notifications                    |
| `AiHelpersSettingsSchema`    | AI providers, feature toggles per AI tool                   |
| `ExerciseSettingsSchema`     | Quiz scoring, feedback, question options                    |
| `LearningPathSettingsSchema` | LP display, prerequisites, SCORM settings                   |
| `DocumentSettingsSchema`     | Upload limits, allowed file types, storage                  |
| `DisplaySettingsSchema`      | UI tabs, sidebar items, theme                               |
| `LanguageSettingsSchema`     | Available languages, default locale                         |
| `AdminSettingsSchema`        | Admin email, admin-specific options                         |

## Accessing Settings

In PHP code:

```php
// Via SettingsManager service
$value = $settingsManager->getSetting('platform.site_name');

// In legacy code
$value = api_get_setting('platform.site_name');
```

In templates:

```twig
{# Read a single setting #}
{{ chamilo_settings_get('platform.site_name') }}

{# Check whether a setting exists #}
{% if chamilo_settings_has('platform.allow_registration') %}
    ...
{% endif %}

{# Get all settings as an array #}
{% set settings = chamilo_settings_all() %}
```

## Setting Structure

Each setting has:

* **Namespace** — The schema category (e.g., `platform`, `security`, `ai_helpers`)
* **Variable** — The setting name (e.g., `site_name`, `allow_registration`)
* **Value** — The current value
* **Type** — Data type (string, boolean, array, etc.)

## Course-Level Settings

Some settings can be overridden at the course level. These are defined in `src/CourseBundle/Settings/` and include:

* Exercise settings per course
* Assignment settings per course
* AI feature toggles per course

## Multi-URL Settings

In multi-URL setups, some settings can be customized per access URL, allowing different portal configurations from the same installation.

Those settings will appear several times in the `settings` table, with different `access_url` values. By default, all settings are associated with `access_url=1`.

## Adding a New Setting

1. Add the setting definition to the appropriate schema class
2. Provide a default value
3. Run database migrations if needed
4. Access the setting via `SettingsManager`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.chamilo.org/developer-guide/developer-guide/backend/settings-system.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
