Managing Your ZendPHP Install Using zendphpctl

zendphpctl is a script for managing your ZendPHP install; from registering the ZendPHP package repository, to installing and configuring PHP versions, to enabling and configuring PHP-FPM, to installing PHP extensions.

Supported operating systems

The script is supported on the following operating system:

  • Linux x86-64

  • Linux arm64

Installation instructions

To install the zendphpctl script:

  1. Download the zendphpctl script and its signature from our repository:
    $ curl -L https://repos.zend.com/zendphp/zendphpctl -o zendphpctl
    $ curl -L https://repos.zend.com/zendphp/zendphpctl.sig -o zendphpctl.sig
  2. Validate the signature:
    echo "$(cat zendphpctl.sig) zendphpctl" | sha256sum --check
  3. If the signature is valid, remove the signature file, then set permissions for the script:
    $ rm zendphpctl.sig
    $ chmod +x zendphpctl

You can either use the script immediately from its current location, or place it somewhere in your $PATH (For example, /usr/local/bin).

Below is a breakdown of the various commands, each with their own set of options. For any of the options below, you can provide the '--help' flag to see the help for that specific command.

Working with the ZendPHP package repository

Installing the ZendPHP package repository (repo install)

The 'repo install' command allows you to install the ZendPHP package repository on your system. You can also provide your credentials to allow immediate access to LTS editions of ZendPHP. If you specify your credentials, you must provide both the '--account' and '--password' flags.

This command was previously named zendphpctl repo-install; please update to use the new command name.

For example:

zendphpctl repo install

Where [options] are any of the following:

Name Short name Description
--account <account>   (Optional) Account or order identifier associated with your credentials
--password <password>   (Optional) Password associated with your credentials

Example 1:

zendphpctl repo install

Example 2:

zendphpctl repo install --account ORDER_ID --password PASSWORD

Providing credentials for the ZendPHP package repository (repo credentials)

The 'repo credentials' command allows you to provide credentials for the ZendPHP package repository on your system, which allows access to LTS editions. When running this option, you must specify both the '--account' and '--password' options.

This command was previously named zendphpctl repo-credentials; please update to use the new command name.

For example:

zendphpctl repo credentials [options]

Where [options] are any of the following:

Name Short name Description
--account <account>   (Required) Account or order identifier associated with your credentials
--password <password>   (Required) Password associated with your credentials

Example:

zendphpctl repo credentials --account ORDER_ID --password PASSWORD

Uninstalling the ZendPHP package repository (repo uninstall)

The 'repo uninstall' command allows you to uninstall the ZendPHP package repository from your system.

This command was previously named zendphpctl repo-uninstall; please update to use the new command name.

Note:

This action DOES NOT remove previously installed ZendPHP packages; it only removes the package repository from your system, preventing further updates and/or installations.

For example:

zendphpctl repo uninstall[options]

Example:

zendphpctl repo uninstall

Working with PHP versions

Installing a new PHP version (php install)

The 'php install' command allows you to install another PHP version in your environment. A PHP minor version must be specified when running this command. The following minor versions are currently supported: 5.6, 7.1, 7.2, 7.3, 7.4, 8.0, and 8.1.

This command was previously named zendphpctl php-install; please update to use the new command name.

For example:

zendphpctl php install [PHP]

Where [PHP] is an argument used to set the PHP minor version to configure.

Example:

zendphpctl php install 7.4

Listing installed PHP versions (php list installed)

The 'php list-installed' command allows you to list all of the installed PHP versions in your environment.

This command was previously named zendphpctl php-list-installed; please update to use the new command name.

For example:

zendphpctl php list-installed

Changing which PHP version is default (php set-default)

The 'php set-default' command allows you to set an installed PHP version as the default to use when calling PHP on the command line. A PHP minor version must be specified when running this command.

This command was previously named zendphpctl php-set-default; please update to use the new command name.

For example:

zendphpctl php set-default [PHP]

Where [PHP] is an argument used to specify the PHP minor version to set as the default.

Example:

zendphpctl php set-default 8.1 

Editing configuration for a PHP version (php config)

The 'php config' command allows you to configure a PHP version for use with PHP-FPM, rather than the default of CLI. If a PHP minor version is not specified, the command will use whatever you have set as your default version.

This command was previously named zendphpctl php-config; please update to use the new command name.

Note:

This command requires the use of a configuration editor. Under Debian-based systems, this is the editor configured via the update-alternatives utility, which is nano by default. However, you can also use vim, neovim, emacs, or another utility. Under RHEL-compatible systems, it is whatever is configured in the $EDITOR environment variable. The command will raise an error if it cannot identify an editor.

For example:

zendphpctl php config [PHP] [options]

Where [PHP] is an argument used to set the PHP minor version to configure (uses default if not provided, see 'php set-default') and [options] are any of the following:

Name Short name Description
--fpm   Configure PHP for use with PHP-FPM (versus CLI)

Example 1:

zendphpctl php config 8.1

Example 2:

zendphpctl php config 7.3 --fpm

Uninstalling an installed PHP version (php uninstall)

The 'php uninstall' command allows you to uninstall a previously installed PHP version. A PHP minor version must be specified when running this command.

This command was previously named zendphpctl php-uninstall; please update to use the new command name.

For example:

zendphpctl php uninstall [PHP]

Where [PHP] is an argument used to set the PHP minor version to uninstall.

Example:

zendphpctl php uninstall 8.1

Executing a script via php (exec)

The 'exec' command allows you to execute the given PHP script(s) using a selected PHP binary. If a PHP minor version is not specified, the command will use whatever you have set as your default version. You can also specify any arguments or flags while running the command.

For example:

zendphpctl exec [options] <arguments>

Where [options] are any of the following:

Name Short name Description
--php <version>   Specifies a PHP minor version to use; uses default PHP version (see 'php set-default') if not specified.

You can also specify <arguments> to execute using the selected PHP version.

Example 1:

zendphpctl exec script.php

Example 2:

zendphpctl exec --php 8.1 test.php

Example 3:

zendphpctl exec --php 7.4 command.php argument and --flags --to-use

Working with PHP-FPM

Determining if FPM support is installed (fpm is-installed)

The 'fpm is-installed' command allows you to determine if FPM is installed for the specified PHP version. If a PHP minor version is not specified, the command will use whatever you have set as your default version.

This command was previously named zendphpctl fpm-is-installed; please update to use the new command name.

For example:

zendphpctl fpm is-installed [options] [PHP]

Where [PHP] is an argument used to set the PHP minor version you are checking for FPM support; uses default if not provided (see 'php set-default').

Example 1:

zendphpctl fpm is-installed

Example 2:

zendphpctl fpm is-installed 8.1

Installing FPM support (fpm install)

The 'fpm install' command allows you to install FPM for an installed PHP version. If a PHP minor version is not specified, the command will use whatever you have set as your default version.

This command was previously named zendphpctl fpm-install; please update to use the new command name.

For example:

zendphpctl fpm install [PHP]

Where [PHP] is an argument used to set the PHP minor version to install FPM support for; uses default if not provided (see 'php set-default').

Example 1:

zendphpctl fpm install

Example 2:

zendphpctl fpm install 8.1

Configuring FPM support (fpm config)

The 'fpm config' command allows you to configure your instance of PHP-FPM. If a PHP minor version is not specified, the command will use whatever you have set as your default version.

This command was previously named zendphpctl fpm-config; please update to use the new command name.

Note:

This command requires the use of a configuration editor. Under Debian-based systems, this is the editor configured via the update-alternatives utility, which is nano by default. However, you can also use vim, neovim, emacs, or another utility. Under RHEL-compatible systems, it is whatever is configured in the $EDITOR environment variable. The command will raise an error if it cannot identify an editor.

For example:

zendphpctl fpm config [PHP]

Where [PHP] is an argument used to set the PHP minor version to configure FPM support for; uses default if not provided (see 'php set-default').

Example 1:

zendphpctl fpm config

Example 2:

zendphpctl fpm config 8.1

Uninstalling FPM support (fpm uninstall)

The 'fpm uninstall' command allows you to uninstall FPM for an installed PHP version. If a PHP minor version is not specified, the command will use whatever you have set as your default version.

This command was previously named zendphpctl fpm-uninstall; please update to use the new command name.

For example:

zendphpctl fpm uninstall [PHP]

Where [PHP] is an argument used to set the PHP minor version to uninstall FPM support for; uses default if not provided (see 'php set-default').

Example 1:

zendphpctl fpm uninstall

Example 2:

zendphpctl fpm uninstall 8.1

Working with PHP extensions

Listing PHP extensions available via package manager (ext list-packages)

The 'ext list-packages' command allows you to list extensions that you can install via the package manager for a specified PHP version. If a PHP minor version is not specified, the command will use whatever you have set as your default version.

This command was previously named zendphpctl ext-list-packages; please update to use the new command name.

For example:

zendphpctl ext list-packages [PHP]

Where [PHP] is an argument used to set the PHP minor version for which to list available extension(s); uses default if not provided (see 'php set-default').

Example 1:

zendphpctl ext list-packages

Example 2:

zendphpctl ext list-packages 7.4

Listing currently enabled PHP extensions (ext list-enabled)

The 'ext list-enabled' command allows you to list extensions currently enabled for a specified PHP version. This includes both packaged extensions and PECL extensions that you have compiled, installed, and enabled for your machine. If a PHP minor version is not specified, the command will use whatever you have set as your default version.

This command was previously named zendphpctl ext-list-enabled; please update to use the new command name.

For example:

zendphpctl ext list-enabled [options] [PHP]

Where [options] are any of the following:

Name Short name Description
--fpm   List extensions enabled only for PHP-FPM (versus CLI) - DEB only

[PHP] is an argument used to set the PHP minor version to list enabled extensions for; uses default if not provided (see 'php set-default').

Example 1:

zendphpctl ext list-enabled

Example 2:

zendphpctl ext list-enabled 7.4

Example 3:

zendphpctl ext list-enabled 7.4 --fpm

Install an extension (ext install)

The 'ext install' command allows you to install one or more PHP extensions. The default behavior is to install existing ZendPHP extension packages if they exist, and otherwise pull the extension from PECL, compile, and install it. If a PHP minor version is not specified, the command will use whatever you have set as your default version.

This command was previously named zendphpctl ext-install; please update to use the new command name.

Notes

  • Some extensions require additional dependencies in order to compile. It is your responsibility to identify and install these dependencies.
  • We do not specify any non-default configure flags; if you have specific flags you want to enable, you need to manually compile the extension yourself.
  • This command can both install package-delivered extensions, and compile and install PECL extensions. If priority (used when loading an extension) or an extension version are provided, it always compiles and installs from source.

For example:

zendphpctl ext install [options] <arguments>

Where [options] are any of the following:

Name Short name Description
--php <version>   Specifies a PHP minor version to use; uses default PHP version (see 'php set-default') if not specified.
--sapi <SAPI>   Install an extension only for a specified SAPI (for example, 'cli' or 'fpm') - DEB only.

You can also specify argument(s) to install one or more extensions. Extensions should be specified with the following format:

{priority-}extension{-version}

{priority-} is used to indicate loading priority; the default, if not specified, is 20, but some extensions (for example, Swoole or OpenSwoole) need to be loaded after other extensions (such as JSON) and should specify a higher priority number (higher loads later). You can use {-version} to indicate a specific extension version to install. If either {priority-} or {-version} are specified, the command will always pull and compile from PECL.

Example 1:

zendphpctl ext install imap

Example 2:

zendphpctl ext install --php 8.1 ldap mysqli redis

Example 3:

zendphpctl ext install --php 7.4 60-swoole-4.8.1

Enabling a PHP extension (ext enable)

The 'ext enable' command allows you to enable one or more PHP extensions. If a PHP minor version is not specified, the command will use whatever you have set as your default version.

This command was previously named zendphpctl ext-enable; please update to use the new command name.

Note:

On DEB systems, this command only enables previously installed extensions, using 'phpenmod'. On RPM system, it installs the related package if it exists, and/or compiles the latest version of a PECL extension. Additionally, for RPM systems, if a compiled extension was previously disabled, it re-enables it.

For example:

zendphpctl ext enable [options] <arguments>

Where [options] are any of the following:

Name Short name Description
--php <version>   Specifies a PHP minor version to use; uses default PHP version (see 'php set-default') if not specified.
--sapi <SAPI>   Install an extension only for a specified SAPI (for example, 'cli' or 'fpm') - DEB only.

You can also specify argument(s) to enable one or more extensions (see the examples below).

Example 1:

zendphpctl ext enable imap

Example 2:

zendphpctl ext enable --php 8.1 ldap mysqli redis

Example 3:

zendphpctl ext enable --php 7.4 --fpm soap

Disabling a PHP extension (ext disable)

The 'ext disable' command allows you to disable one or more PHP extensions. If a PHP minor version is not specified, the command will use whatever you have set as your default version.

This command was previously named zendphpctl ext-disable; please update to use the new command name.

Note:

On RPM systems, the related package (if the extension is available as a package) is removed; otherwise, the configuration for the package is updated to comment out the line that enables the extension. On DEB systems, 'phpdismod' is used to disable the extension(s).

For example:

zendphpctl ext disable [options] <arguments>

Where [options] are any of the following:

Name Short name Description
--php <version>   Specifies a PHP minor version to use; uses default PHP version (see 'php set-default') if not specified.
--sapi <SAPI>   Install an extension only for a specified SAPI (for example, 'cli' or 'fpm') - DEB only.

You can also specify argument(s) to enable one or more extensions (see the examples below).

Example 1:

zendphpctl ext disable imap

Example 2:

zendphpctl ext disable --php 8.1 ldap mysqli redis

Example 3:

zendphpctl ext disable --php 7.4 --fpm soap

Updating the zendphpctl script (self-update)

The 'self-update' command allows you to update the zendphpctl script to the latest version.

Note:

Depending on where you have installed the script and the permissions you have assigned, this script might need to be run as root.

For example:

zendphpctl self-update

Example:

zendphpctl self-update

Working with Apache mod_php support

Note:

The following commands are available as of version 0.2.19.

Installing mod_php support (apache mod_php install)

The 'apache mod_php install' command installs the Apache mod_php SAPI for the given PHP version. If no PHP version is provided, it uses the default (assuming at least one version has been installed).

For example:

zendphpctl apache mod_php install [PHP]

Where [PHP] is an argument used to set the PHP minor version to configure.

Example 1:

zendphpctl apache mod_php install

Example 2:

zendphpctl apache mod_php install 7.4

Checking if mod_php support is installed (apache mod_php is-installed)

The 'apache mod_php is-installed' command determines if Apache mod_php SAPI support is installed for the given PHP version. If no PHP version is provided, it uses the default (assuming at least one version has been installed).

For example:

zendphpctl apache mod_php is-installed [PHP]

Where [PHP] is an argument used to set the PHP minor version to configure.

Example 1:

zendphpctl apache mod_php is-installed

Example 2:

zendphpctl apache mod_php is-installed 7.4

Uninstalling mod_php support (apache mod_php uninstall)

The 'apache mod_php uninstall' command uninstalls the Apache mod_php SAPI for the given PHP version, if it was previously installed. If no PHP version is provided, it uses the default (assuming at least one version has been installed).

For example:

zendphpctl apache mod_php uninstall [PHP]

Where [PHP] is an argument used to set the PHP minor version to configure.

Example 1:

zendphpctl apache mod_php uninstall

Example 2:

zendphpctl apache mod_php uninstall 7.4

Upgrading from previous versions

In zendphpctl version 0.2.20, command names now use a hierarchical, nested subcommand structure. All previous command names continue to work, but we recommend updating any automation scripts to use the new commands. The following is a table detailing the original command names, and the new commands to utilize.

Original command name (<0.2.20) New command name (>=0.2.20)
zendphpctl ext-disable zendphpctl ext disable
zendphpctl ext-enable zendphpctl ext enable
zendphpctl ext-install zendphpctl ext install
zendphpctl ext-list-enabled zendphpctl ext list-enabled
zendphpctl ext-list-disabled zendphpctl ext list-disabled
zendphpctl ext-list-packages zendphpctl ext list-packages
zendphpctl fpm-config zendphpctl fpm config
zendphpctl fpm-install zendphpctl fpm install
zendphpctl fpm-is-installed zendphpctl fpm is-installed
zendphpctl fpm-uninstall zendphpctl fpm uninstall
zendphpctl php-config zendphpctl php config
zendphpctl php-exec zendphpctl php exec
zendphpctl php-install zendphpctl php install
zendphpctl php-list-installed zendphpctl php list-installed
zendphpctl php-set-default zendphpctl php set-default
zendphpctl php-uninstall zendphpctl php uninstall
zendphpctl repo-credentials zendphpctl repo credentials
zendphpctl repo-install zendphpctl repo install
zendphpctl repo-uninstall zendphpctl repo uninstall
zendphpctl zendhq-token zendphpctl zendhq token
zendphpctl zray-plugin-disable zendphpctl zray plugin disable
zendphpctl zray-plugin-enable zendphpctl zray plugin enable
zendphpctl zray-plugins-install zendphpctl zray plugin install
zendphpctl zray-plugins-list zendphpctl zray plugin list