The php_include model allows you to create php include "snippets" that can be reused within php_classes. This model should be rarely used since there are usually more appropriate ways to share content. For example, the globals model can be used to define shared constants. The php_class model can also be used to share php logic. Nevertheless, the php_include model can be used to share php logic as needed. Include files can also be included using the $include function.

Enter the php code into the editor without coding <?php to introduce the php and within terminating the php code with ?>. These will be added automatically when the include file is stowed.

By default, the include file will be saved in the site's private_data includes folder. If you include a path in the include name, it will be saved within a subfolder of the site's include folder.

Changing the Generated Code

With most GenHelm models you want to avoid modifying the code generated by the model since this will render the code out of sync with the specification used to generate the code. The php_include model recognizes that there may be times when you want to change the resultant code directly. This primarily happens during debugging when you often want to take advantage of your editor's debugging features to help ascertain what the php code should be changed into. 

The generated code is always structured using a special comment to introduce and close the php code as we see here:

//custom function include body {
your code would appear here
//custom }

If you need to make changes outside of the GenHelm Integrated Environment you may do so provided the changes are made within the opening and closing comments shown above. In such a case, the code within these comments will automatically be read from the generated source code the next time you edit the specification for this include file within GenHelm.

Note that you won't be able to promote this code into production until it has been regenerated in GenHelm thereby bringing the specification and the generated code back into sync.


Sample php_include definition
🡇
Sample generated php_include code