Custom scripts in 25.11 Getting Parse_config() Crash
-
In 25.7 I had used a couple custom scripts to change a gateway rule via local ssh
the script looks like this```
code_text<?php require_once("globals.inc"); require_once("filter.inc"); require_once("util.inc"); require_once("config.inc"); global $config; $config = parse_config(true); foreach ($config['filter']['rule'] as &$value) { if (strpos(strtolower($value['descr']), 'allow access') !== false) { if (strpos(strtolower($value['gateway']), 'wan') !== false) { $value['gateway'] = 'vpnbalance'; } else { $value['gateway'] = 'WAN'; } } } write_config("Configuration Changed"); $retval |= filter_configure(); ?> Now with 25.11 I get a Crash Report with the following error. --- Crash report details: PHP Errors: [13-Dec-2025 12:01:50 America/Chicago] PHP Fatal error: Uncaught Error: Call to undefined function parse_config() in /usr/local/bin/kvpn.php:12 Stack trace: #0 {main} thrown in /usr/local/bin/kvpn.php on line 12 ___ It appears that the parse_config() function has been moved or no longer exists. Any ideas? -
@townsenk64 You need to use the config_* functions. The documentation on the switch to PHP 8 (back in 23.01) should get you going:
https://docs.netgate.com/pfsense/en/latest/development/php-config-arrays.html
-
@dennypage Thanks that sure enough did get me started and AI had me a working script in less that a minute.
Copyright 2026 Rubicon Communications LLC (Netgate). All rights reserved.