Example: PHP Executor with the SQLSRV Module

Follow an example to configure a PHP executor with the SQLSRV module.


Intended audience: ProcessMaker Administrators, coding engineers

Tags: Script Executor; PHP; SQLSRV

This example outlines best practices when creating a PHP script executor with the SQLSRV module in ProcessMaker. This example ensures a seamless integration of the SQL Server functionality into your scripts.

Configure PHP Executor with the SQLSRV Module

Follow the next steps to configure the PHP executor with the SQLSRV module:

  1. View your Script Executors. The Script Executors page displays.

  2. Click the +Script Executor button. The Add New Script Executor screen displays.

  3. In the Name setting, enter the unique name for the Script Executor. This name displays from Script configuration settings, so enter a descriptive name so that Process designers configuring their Scripts understand what customization this Script Executor provides. For example, you can enter PHP + SQLSRV.

  4. In the Description setting, enter a description for the Script Executor.

  5. From the Language setting, select the PHP programming language that the Script Executor uses to run the Script. After selecting the programming language, the default Dockerfile content to run Scripts using that language displays in the Dockerfile setting. The Dockerfile content includes the SDK for that language.

  6. From the Dockerfile setting, append the default Dockerfile content with the Docker commands the Script Executor runs when it builds the Docker container. Consider following best practices for writing Dockerfiles. For this example, enter the following code to integrate correctly the SQL Server functionality.

    # Fix debconf warnings upon build
    ARG DEBIAN_FRONTEND=noninteractive
    # Install selected extensions and other tools
    RUN apt-get update \
    && apt-get -y --no-install-recommends install apt-utils libxml2-dev gnupg apt-transport-https \
    && apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
    # Install curl and git
    RUN apt-get update \
    && apt-get -y install git curl\
    && apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
    # Install MS ODBC Driver for SQL Server
    RUN curl <https://packages.microsoft.com/keys/microsoft.asc> | apt-key add - \
    && curl <https://packages.microsoft.com/config/debian/8/prod.list> > /etc/apt/sources.list.d/mssql-release.list \
    && apt-get update \
    && apt-get -y --no-install-recommends install msodbcsql unixodbc-dev mssql-tools\
    && pecl install pdo_sqlsrv-5.8.1 \
    && pecl install sqlsrv-5.8.1 \
    && echo "extension=pdo_sqlsrv.so" >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/30-pdo_sqlsrv.ini \
    && echo "extension=sqlsrv.so" >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/30-sqlsrv.ini \
    && apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
    # Check installation
    RUN php -m
  8. Click Save and Build to build the Docker container from which the Script Executor runs Scripts. The Build Command Output setting displays below the Dockerfile setting as the Script Executor builds the Docker container in real-time. If the Docker container builds successfully, the following message displays: Executor Successfully Built. You can now close this window. If building the Docker container is unsuccessful, the following message displays: Error Building Executor. See Output Above.. The Build Command Output setting displays the Dockerfile error.

  9. Click Close. The PHP Script Executor with the SQLSRV module is now available in the list of languages when creating a new script.

Last updated

© Copyright 2000-2024 ProcessMaker Inc. All rights reserved.