Hướng dẫn mlocati php-extension-installer
Show
Easy installation of PHP extensions in official PHP Docker imagesThis repository contains a script that can be used to easily install a PHP extension inside the official PHP Docker images. The script will install all the required APT/APK packages; at the end of the script execution, the no-more needed packages will be removed so that the image will be much smaller. Supported docker images are all the Alpine/Debian versions, except for PHP 5.5 where we only support Debian 8 (jessie) (that is, UsageYou have two ways to use this script within your For example, here some Downloading the script on the flyWith the DockerfileFROM php:7.2-cli ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ RUN chmod +x /usr/local/bin/install-php-extensions && \ install-php-extensions gd xdebug With curlFROM php:7.2-cli RUN curl -sSLf \ -o /usr/local/bin/install-php-extensions \ https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \ chmod +x /usr/local/bin/install-php-extensions && \ install-php-extensions gd xdebug Copying the script from a Docker imageFROM php:7.2-cli COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/ RUN install-php-extensions gd xdebug
Installing specific versions of an extensionSimply append install-php-extensions xdebug-2.9.7 The script also
supports resolving compatible versions by prefixing the version with a caret ( # Install the most recent xdebug 2.x version (for example 2.9.8) install-php-extensions xdebug-^2 # Install the most recent xdebug 2.8.x version (for example 2.8.1) install-php-extensions xdebug-^2.8 Pre-release versions extensions available on install-php-extensions xdebug-beta TIP: When the latest version available on install-php-extensions mongodb-stable Installing from source codeYou can also install PHP extensions from source code (provided that it comes with a Accepted formats are:
Installing composerYou can also install composer, and you also can specify a major version of it, or a full version. Examples: # Install the latest version install-php-extensions @composer # Install the latest 1.x version install-php-extensions @composer-1 # Install a specific version install-php-extensions @composer-2.0.2 Issue with Let's Encrypt certificatesThe root CA certificate of Let's Encrypt changes (more details here).
This script can fix this issue: simply pass install-php-extensions @fix_letsencrypt Supported PHP extensions
Number of supported extensions: 127 PS: the pre-installed PHP extensions are excluded from this list. You can list them with the following command (change
ConfigurationYou can configure the behavior of the script, as well as fine-tune some extensions in order fit your needs, by using environment variables. Here's an example: IPE_LZF_BETTERCOMPRESSION=1 install-php-extensions lzf Here's the list of all the supported environment variables:
Special requirementsSome extensions have special requirements:
How do I know which Linux distribution I am using?You can run this command: For example:
TestsWhen submitting a pull request, a GitHub Action is executed to check if affected PHP extensions actually work (see below). Furthermore, we also check that new versions of extensions in the PECL repository will still work. This is done on a scheduled basis with another
GitHub Action. How to contributeFormatting codeBefore submitting any pull
request, you should execute the If you don't do that, and if there's a coding style error, you'll see that the The error will be something like this: --- filename.orig +++ filename @@ -line number,7 +line number,7 @@ good line of code #1 good line of code #2 good line of code #3 - the original line with a wrong coding style + the line wrong coding style that has been corrected good line of code #4 good line of code #5 good line of code #6 So, you should fix highlighted line (the one(s) at Adding support to a new PHP extension?
See this pull request for an example. Changing the supported PHP versions for an already supported PHP extension?
See this pull request for an example. Improving code for an already supported extension?If you change some code that affects one or more extensions, please add a line with Here's an example of a commit message:
Tests only check the installation of a single PHP extension at a time. If you want to test installing more PHP extensions at the same time, use a commit message like this:
If your pull request contains multiple commits, we'll check the "Test:" message of every commit. If you want to stop parsing next commits, add
See this pull request for an example. PHP requirements and configure optionsPHP extensions published on the PECL archive contain a
It's a rather tedious task, so I developed a project that lets you easily check those constraints: you can find it at https://mlocati.github.io/pecl-info (here you can find its source code). For the maintainersSee the Do you want to really say thank you?You can offer me a monthly coffee or a one-time coffee😉 |