For Debian, installation use apt, to use pecl, you could use this package.
sudo apt install -y php-pear
For macOS, installation use Homebrew, you could use some packages.
brew install pkg-config zlib
For Windows, you could use this guide: https://gist.github.com/ewilan-riviere/8210ba3dc4cf77e57c4069ae0008d3f1
PHP extensions can be installed with PECL or directly from repository compilation. If you change your PHP version, you will have to reinstall all extensions you need once (you could switch between PHP versions and extensions will stay installed, by version).
Today, some extensions are maintained and some are not, check errors if you have it and check issues on extensions GitHub repositories to find solutions. For extensions listed here, you can install it with PHP 8.2.
Check pear.php.net.
PEAR is a framework and distribution system for reusable PHP components.
PHP can use Pear with PECL package pear.
- GitHub: <
- PECL: https://pecl.php.net/package/pear
sudo apt install -y php-pearbrew install pkg-config zlibcurl -O http://pear.php.net/go-pear.phar
sudo php -d detect_unicode=0 go-pear.pharsudo pecl install pear/pear-core-minimalCheck www.swoole.com.
Swoole is an event-driven, asynchronous, coroutine-based concurrency library with high performance for PHP.
PHP can use Swoole with PECL package swoole.
- GitHub: https://github.com/swoole/swoole-src
- PECL: https://pecl.php.net/package/swoole
- PHP docs: https://www.php.net/manual/en/book.swoole.php
Install with default options.
sudo apt install -y g++ make
git clone https://github.com/swoole/swoole-src.git && \
cd swoole-src
phpize
./configure
sudo make
sudo make installYou can use pecl install swoole, install from source is recommanded from GitHub readme for advanced users.
Add manually extension.
Check if installed
php -m | grep swooleCheck github.com.
PCOV - CodeCoverage compatible driver for PHP
PHP can use ImageMagick with PECL package imagick.
Make sure you have pcre2 installed on macOS, you can check 'pcre2.h' file not found if you have errors.
git clone https://github.com/krakjoe/pcov.git
cd pcov
phpize
./configure --enable-pcov
make
make testmake install # or sudo make installNow you have to add extension to your php.ini, you can check Add manually extension.
You can check if extension is installed with php -m | grep pcov.
Warning
If you don't have
pcovinphp -m, you have to addextension=pcovto yourphp.inifile.
Use this guide https://gist.github.com/ewilan-riviere/8210ba3dc4cf77e57c4069ae0008d3f1#pcov.
Check redis.io.
The open source, in-memory data store used by millions of developers as a database, cache, streaming engine, and message broker.
PHP can use Redis with PECL package redis or composer package predis/predis.
- GitHub PECL: https://github.com/phpredis/phpredis
- PECL: http://pecl.php.net/package/redis
- GitHub
predis/predis: https://github.com/predis/predis
Download redis-stable
wget https://download.redis.io/redis-stable.tar.gzCompile redis-stable
tar -xzvf redis-stable.tar.gz
cd redis-stable
makeInstall redis-stable
sudo make installRun redis-server
redis-serverCreate redis.conf
sudo cp ./redis.conf /etc/redis.confCreate service
sudo vim /etc/systemd/system/redis.service[Unit]
Description=Redis Server
After=network.target
[Service]
ExecStart=/usr/local/bin/redis-server /etc/redis.conf
ExecStop=/usr/local/bin/redis-server shutdown
Restart=always
[Install]
WantedBy=multi-user.targetsudo systemctl daemon-reload
sudo systemctl enable redis.service
sudo systemctl start redis.servicesudo systemctl status redis.servicesudo apt install lsb-release curl gpg -ycurl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.listsudo apt update
sudo apt install redis -ysudo service redis startbrew install redisbrew services start redisYou can install extension OR composer package.
git clone https://github.com/phpredis/phpredis.git
cd phpredis
phpize
./configure [--enable-redis-igbinary] [--enable-redis-msgpack] [--enable-redis-lzf [--with-liblzf[=DIR]]] [--enable-redis-zstd]
make && make installsudo echo "extension=redis.so" >> /etc/php.iniPredis is a Redis client written entirely in PHP and does not require any additional extensions.
composer require predis/predisCheck if Redis is installed (only for PECL extension)
php -m | grep redisCheck imagemagick.org.
ImageMagick, invoked from the command line as magick, is a free and open-source cross-platform software suite for displaying, creating, converting, modifying, and editing raster images. Created in 1987 by John Cristy, it can read and write over 200 image file formats. It is widely used in open-source applications.
PHP can use ImageMagick with PECL package imagick.
- GitHub: https://github.com/Imagick/imagick
- PECL: http://pecl.php.net/package/imagick
- PHP docs: https://www.php.net/manual/en/book.imagick.php
sudo apt install -y imagemagick ghostscript libmagickwand-devgit clone https://github.com/Imagick/imagick
cd imagick
phpize && ./configure
makemake install # or sudo make installbrew install imagemagick ghostscriptAdd to path
echo 'export MAGICK_HOME=/opt/homebrew/opt/imagemagick/' >> ~/.zshrc
echo 'export PATH="/opt/homebrew/opt/imagemagick/bin:$PATH"' >> ~/.zshrcgit clone https://github.com/Imagick/imagick
cd imagick
phpize && ./configure
makemake install # or sudo make installUse this guide https://gist.github.com/ewilan-riviere/8210ba3dc4cf77e57c4069ae0008d3f1#imagick.
Check if extension is installed with php -m | grep imagick.
Warning
If you have an error like this
attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAuthorized/408.Check you have
ghostscriptinstalled withgs --versionAnd if it's okay, open/etc/ImageMagick-6/policy.xmlto remove some lines<!-- disable ghostscript format types --> <!-- <policy domain="coder" rights="none" pattern="PS" /> --> <!-- <policy domain="coder" rights="none" pattern="PS2" /> --> <!-- <policy domain="coder" rights="none" pattern="PS3" /> --> <!-- <policy domain="coder" rights="none" pattern="EPS" /> --> <!-- <policy domain="coder" rights="none" pattern="PDF" /> --> <!-- <policy domain="coder" rights="none" pattern="XPS" /> -->
Check www.win-rar.com
WinRAR is a trialware file archiver utility for Windows, developed by Eugene Roshal of win.rar GmbH. It can create and view archives in RAR or ZIP file formats, and unpack numerous archive file formats.
PHP can use WinRAR with PECL package rar.
- GitHub: https://github.com/cataphract/php-rar
- PECL: https://pecl.php.net/package/rar
- PHP docs: https://www.php.net/manual/en/book.rar.php
WARNING
rarextension is not actively maintained. With recent PHP versions, you will have some errors on installation. You have to compile by yourself the extension. Check Troubles section.
With recent PHP versions, you could have some problem with installation from package managers.
To install package, you have to compile the package, you can find an example here.
You have to add non-free into your sources.list file, like deb http://... <distrib> main non-free and execute apt update.
sudo apt install -y rarcd ~
git clone https://github.com/cataphract/php-rar
cd php-rar
phpize
./configure
makemake install # or sudo make installbrew install rar unrarcd ~
git clone https://github.com/cataphract/php-rar
cd php-rar
phpize
./configure
makemake install # or sudo make installUse this guide https://gist.github.com/ewilan-riviere/8210ba3dc4cf77e57c4069ae0008d3f1#rar.
You will find PHP extension here: ~/php-rar/modules/rar.so. To use it, find PECL extension directory.
pecl_path=$(pecl config-get ext_dir) # Find PECL extension directory
phpini_path=$(php -i | grep /.+/php.ini -oE) # Find php.ini path
sudo cp ~/php-rar/modules/rar.so $pecl_path # Copy extension to PECL extension directory
echo "extension=rar.so" | sudo tee -a $phpini_path # Add extension to php.iniNow you remove local php-rar.
rm -r ~/php-rarNote: PHP 8.2 For PHP 8.2, even manual compilation, you will have maybe some errors. A pull request offer to fix this problem, in some months PR could be accepted. But even with this bug, PHP and
rarextension will work.
php -m | grep rarIf you see rar, extension is ready.
Check www.microsoft.com
Microsoft SQL Server is a relational database management system developed by Microsoft. As a database server, it is a software product with the primary function of storing and retrieving data as requested by other software applications—which may run either on the same computer or on another computer across a network.
PHP can use SQL Server with PECL package sqlsrv.
- GitHub: https://github.com/Microsoft/msphpsql
- PECL: https://pecl.php.net/package/sqlsrv
- PHP docs: https://www.php.net/manual/en/book.sqlsrv.php
sudo pecl install sqlsrv pdo_sqlsrvbrew install autoconf automake libtoolInstall Microsoft ODBC
brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
brew update
HOMEBREW_ACCEPT_EULA=Y brew install msodbcsql18 mssql-toolssudo pecl install sqlsrv pdo_sqlsrvTo upgrade
sudo pecl upgrade sqlsrv
sudo pecl upgrade pdo_sqlsrvsudo CXXFLAGS="-I/opt/homebrew/opt/unixodbc/include/" LDFLAGS="-L/opt/homebrew/lib/" pecl install sqlsrv
sudo CXXFLAGS="-I/opt/homebrew/opt/unixodbc/include/" LDFLAGS="-L/opt/homebrew/lib/" pecl install pdo_sqlsrvTo upgrade
sudo CXXFLAGS="-I/opt/homebrew/opt/unixodbc/include/" LDFLAGS="-L/opt/homebrew/lib/" pecl upgrade sqlsrv
sudo CXXFLAGS="-I/opt/homebrew/opt/unixodbc/include/" LDFLAGS="-L/opt/homebrew/lib/" pecl upgrade pdo_sqlsrvphp -m | grep sqlsrvIf you see sqlsrv, extension is ready.
You can check pecl package versions
pecl listOn macOS you need to install pcre2 and link it to current PHP version.
brew install pcre2Check current versions
ls /opt/homebrew/Cellar/pcre2/
ls /opt/homebrew/Cellar/php/Link pcre2 to current php.
ln -s /opt/homebrew/Cellar/pcre2/YOU_VERSION/include/pcre2.h /opt/homebrew/Cellar/php/YOU_VERSION/include/php/ext/pcre/pcre2.hphp_version=$(php -v | grep ^PHP | awk '{print $2}')
pcre2_version=$(ls /opt/homebrew/Cellar/pcre2/)
sudo ln -s /opt/homebrew/Cellar/pcre2/$pcre2_version/include/pcre2.h /opt/homebrew/Cellar/php/$php_version/include/php/ext/pcre/pcre2.hYou can now compile again.
After compilation, you have to add extension to your PHP installation.
Find your php.ini file.
php --iniUse any editor to add extension.
sudo vim /your/path/to/php.iniIn your php.ini, add this to the first line.
extension="<extension>.so"pecl_path=$(pecl config-get ext_dir)
phpini_path=$(php -i | grep /.+/php.ini -oE)
sudo cp ./modules/<extension>.so $pecl_path
sudo echo "extension=<extension>.so" > $phpini_pathCheck if PHP can use extension.
php -m | grep <extension>If you see extension, extension is ready.
With PHP Intelephense, you can add imagick to your settings.json.
{
"intelephense.stubs": ["imagick", "rar"]
}