SuperAPI AI 工具集

bitrix-settings

通用与其它

查看项目

更新于 10-15 17:30

技能介绍

用途:处理 Bitrix 框架内核配置文件 .settings.php / .settings_extra.php,说明读取哪个文件、各配置段含义与写入行为。基线 main 23.0+,验证版本 main 26.800.0。

文件解析:主文件优先读 /local/.settings.php(main 24.100 起),否则读 /bitrix/.settings.php,只读其一;/local 文件会替换内核文件,需复制所有段(含 connections)。额外文件优先 /local/.settings_extra.php,否则 /bitrix/.settings_extra.php,只读其一,在主文件之后加载;每个顶层段整体替换,不做深度合并。项目段(闭包、密钥、routing、loggers、messenger)建议放入 /local/.settings_extra.php,它会遮蔽 /bitrix 中的同名文件,需把其中段迁移过来。

主要能力:可配置 connections、cache、cache_flags、session、cookies、crypto、exception_handling、routing、messenger、loggers、composer、http_client_options、pull、smtp、ui、default_language、services 等全局段;模块级 /local/modules/<id>/.settings.php 支持 services、controllers、console、messenger、rest(v3)。SMTP 支持 smtp 与按发件人的 SMTP 配置。

使用方式:格式为 'section' => ['value' => [...], 'readonly' => true],readonly 段会被运行时 Configuration::add()/delete() 及后台表单跳过;读取用 Configuration::getValue('section')。内核/后台写入(Configuration::setValue()、设置表单)会用 var_export 把主文件数据写回主文件,主文件中的闭包会在下次写入时出错,额外文件不会被重写。

限制:无 validation 段;routing 仅全局。站点检查器与 services/quickway.php 只读 /bitrix/.settings.php,需保持其有效。IsConfigFile() 仅禁止文件管理器访问 /bitrix/.settings.php,不禁止 /local/.settings*.php。php_interface/dbconn.php(main 24.100 起为 /local,否则 /bitrix)仍必需。