Using the zendphpctl script

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

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.

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.

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.

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.

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.

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.

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.

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.

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.

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-is-installed' 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.

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.

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.

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.

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.

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.

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.

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.

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