<?php //Change this to match your path $myPHPStormConfigFile = '/Users/kbrill/Library/Preferences/PhpStorm2019.3/jba_config/templates/PHP.xml'; global $beanList; $xml = "<templateSet group=\"PHP\">\n"; foreach ($beanList as $moduleName => $englishName) { if (!empty($moduleName)) { $bean = BeanFactory::newBean($moduleName); if (is_object($bean)) { $fieldDefs = array_keys($bean->field_defs); $xml .= assembleXML($moduleName, $fieldDefs); } } } $xml .= '</templateSet>'; $fp = fopen($myPHPStormConfigFile, 'w'); fwrite($fp, $xml); fclose($fp); function assembleXML($moduleName, $fieldDefs) { $fieldString = 'enum("' . implode('","', $fieldDefs) . '")'; return "<template name=\"@{$moduleName}Bean\" value=\"\${$moduleName}Bean->\$field$\" description=\"Field Names for {$moduleName}\" toReformat=\"true\" toShortenFQNames=\"true\"> <variable name=\"field\" expression=\"{$fieldString}\" defaultValue=\"\" alwaysStopAt=\"true\" /> <context> <option name=\"PHP\" value=\"true\" /> </context> </template>"; }