Modifying pattern instances by using PHP
Add PHP code to a code plug-in project to modify a pattern instance when the pattern instance is generated by a pattern user.
Before you begin
About this task
If you added PHP support when you created the code plug-in, a PHP template and example scripts are created and added to the project. Alternatively, you can write your own PHP script. Regardless of how the script is created, you must add your own code within the script to complete the steps you require when the pattern instance is generated. For examples of PHP code for completing common tasks, see Examples of PHP API code. For reference information about the PHP pattern authoring API, see PHP API for user-defined patterns.
To select a PHP script to run when a pattern instance is generated:
- If the Add Java or PHP Code window
is not open, in the Pattern
Configuration tab of
the Pattern Authoring editor, click Add.
The Add Java or PHP Code window opens.
- In the Type of code list, select PHP.
- In the Project name list, select the project or plug-in that contains the PHP script that you want to run when a pattern instance is generated. If the required plug-in is installed, but is not in your workspace, click Browse and select the required plug-in.
- In the PHP file name list, select
the name of the script you want to run when a pattern instance is
generated. The PHP file name list shows all the PHP scripts in the project or plug-in that you selected.
- Optional: To write the output of the PHP script
to a file, select Write the output from the PHP file into
an output file.
- In the Pattern instance project list, select the pattern instance project in which you want to include the output file.
- In the Output file name field,
enter a name for the output file. You can include a path in this field, for example scripts/example.mqsc to write the output to the scripts folder.
- Click OK. The Add Java or PHP Code window closes and the PHP script that you selected is shown in the Java and PHP Code section of the Pattern Configuration tab.
- Optional: The Java and PHP code listed in the Java and PHP Code section of the Pattern Configuration tab runs from top to bottom when a pattern instance is generated. To change the order in which the code runs, select the entry you want to move in the Java and PHP Code section and click the Up or Down button to change the position of the entry in the list.