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-pear
brew install pkg-config zlib
curl -O http://pear.php.net/go-pear.phar
sudo php -d detect_unicode=0 go-pear.phar
sudo pecl install pear/pear-core-minimal
Check 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 install
You 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 swoole
Check 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 test
make install # or sudo make install
Now 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
pcov
inphp -m
, you have to addextension=pcov
to yourphp.ini
file.
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.gz
Compile redis-stable
tar -xzvf redis-stable.tar.gz
cd redis-stable
make
Install redis-stable
sudo make install
Run redis-server
redis-server
Create redis.conf
sudo cp ./redis.conf /etc/redis.conf
Create 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.target
sudo systemctl daemon-reload
sudo systemctl enable redis.service
sudo systemctl start redis.service
sudo systemctl status redis.service
sudo apt install lsb-release curl gpg -y
curl -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.list
sudo apt update
sudo apt install redis -y
sudo service redis start
brew install redis
brew services start redis
You 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 install
sudo echo "extension=redis.so" >> /etc/php.ini
Predis is a Redis client written entirely in PHP and does not require any additional extensions.
composer require predis/predis
Check if Redis is installed (only for PECL extension)
php -m | grep redis
Check 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-dev
git clone https://github.com/Imagick/imagick
cd imagick
phpize && ./configure
make
make install # or sudo make install
brew install imagemagick ghostscript
Add to path
echo 'export MAGICK_HOME=/opt/homebrew/opt/imagemagick/' >> ~/.zshrc
echo 'export PATH="/opt/homebrew/opt/imagemagick/bin:$PATH"' >> ~/.zshrc
git clone https://github.com/Imagick/imagick
cd imagick
phpize && ./configure
make
make install # or sudo make install
Use 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
ghostscript
installed withgs --version
And if it's okay, open/etc/ImageMagick-6/policy.xml
to 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
rar
extension 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 rar
cd ~
git clone https://github.com/cataphract/php-rar
cd php-rar
phpize
./configure
make
make install # or sudo make install
brew install rar unrar
cd ~
git clone https://github.com/cataphract/php-rar
cd php-rar
phpize
./configure
make
make install # or sudo make install
Use 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.ini
Now you remove local php-rar
.
rm -r ~/php-rar
Note: 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
rar
extension will work.
php -m | grep rar
If 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_sqlsrv
brew install autoconf automake libtool
Install Microsoft ODBC
brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
brew update
HOMEBREW_ACCEPT_EULA=Y brew install msodbcsql18 mssql-tools
sudo pecl install sqlsrv pdo_sqlsrv
To upgrade
sudo pecl upgrade sqlsrv
sudo pecl upgrade pdo_sqlsrv
sudo 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_sqlsrv
To 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_sqlsrv
php -m | grep sqlsrv
If you see sqlsrv
, extension is ready.
You can check pecl
package versions
pecl list
On macOS you need to install pcre2
and link it to current PHP version.
brew install pcre2
Check 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.h
php_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.h
You can now compile again.
After compilation, you have to add extension to your PHP installation.
Find your php.ini
file.
php --ini
Use any editor to add extension.
sudo vim /your/path/to/php.ini
In 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_path
Check 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"]
}