Php pecl for windows

Installing a PHP extension on Windows

There are two ways to load a PHP extension on Windows: either compile it into
PHP, or load the DLL.
Loading a pre-compiled extension is the easiest and preferred way.

To load an extension, it has to be available as a
.dll
file on the system.
All the extensions are automatically and periodically compiled by the PHP
Group (see next section for the download).

To compile an extension into PHP, please refer to the
building from source
documentation.

To compile a standalone extension (aka a DLL file), please refer to the
building from source
documentation.
If the DLL file is available neither with the PHP distribution nor in PECL,
it may be necessary to compile it before the extension can be used.

Where to find an extension?

PHP extensions are usually called php_*.dll (where the
star represents the name of the extension), and they are located under the
PHP\ext
folder.

PHP ships with the extensions most useful to the majority of developers.
They are called bundled extensions.

However, if the bundled extensions do not provide the needed functionality,
one extension that does may still be found in » PECL.
The PHP Extension Community Library (PECL) is a repository for PHP
Extensions, providing a directory of all known extensions and hosting
facilities for downloading and developing PHP extensions.

If an extension has been developed for particular uses, it may be hosted on
PECL so that others with the same needs can benefit from it.
A nice side effect is that it’s a good chance to receive feedback,
(hopefully) thanks, bug reports and even fixes/patches.
Before submitting an extension for hosting on PECL, please read
» PECL submit.

Which extension to download?


Many times, there will be several versions of each DLL available:


  • Different version numbers (at least the first two numbers should match)

  • Different thread safety settings

  • Different processor architecture (x86, x64, …)

  • Different debugging settings

  • etc.

Keep in mind that the extension settings should match all the settings of
the PHP executable being used.
The following PHP script will tell all about the PHP
settings:

Or from the command line, run:

drive:\path\to\php\executable\php.exe -i

Loading an extension

The most common way to load a PHP extension is to include it in
the php.ini configuration file.
Please note that many extensions are already present in the php.ini and
that the semicolon only needs to be removed to activate them.

Note that, as of PHP 7.2.0, the extension name may be used
instead of the extension’s file name.
As this is OS-independent and easier, especially for newcomers, it becomes
the recommended way of specifying extensions to load.
File names remain supported for compatibility with prior versions.

;extension=php_extname.dll
extension=php_extname.dll
; As of PHP 7.2.0, prefer:
extension=extname
zend_extension=another_extension

However, some web servers are confusing because they do not use
the php.ini located alongside the PHP executable.
To find out where the actual php.ini resides, look for its path
in phpinfo():

Configuration File (php.ini) Path  C:\WINDOWS
Loaded Configuration File   C:\Program Files\PHP\8.2\php.ini

After activating an extension, save php.ini, restart the web server, and
check phpinfo() again.
The new extension should now have its own section.

Resolving problems

If the extension does not appear in phpinfo(),
the logs should be checked to learn where the problem comes from.

If PHP is being used from the command line (CLI), the extension loading
error can be read directly on the screen.

If PHP is being used with a web server, the location and format of the logs
vary depending on the software.
Please read the web server documentation to locate the logs, as it has
nothing to do with PHP itself.

Common problems are the location of the DLL and the DLLs it depends on, the
value of the «extension_dir»
setting inside php.ini and compile-time setting mismatches.

If the problem lies in a compile-time setting mismatch, probably the DLL
downloaded is not the right one.
Try downloading the extension again with the proper settings.
Again, phpinfo() can be of great help.

Found A Problem?

j dot o dot l dot a dot n at bk dot ru

1 year ago

In order for php to see extensions, it is necessary to specify the root folder when specifying the address to the directory with extensions in php.ini. For example extension_dir = "php/ext"

bk at kaelberer-aio dot de

2 years ago

In addition to the helpful comments of ferdnyc and dario: A few weeks ago I've set up a new W11 using PHP 8.1. (as a module) with Apache. It was working fine.
Today i wanted to install the PECL-extension php-amqp. This extension comes with two additional files that are said to be placed in PHPs main directory. It worked fine running from the command prompt but with Apache the extension failed with "Unable to load dynamic library 'amqp'".
I tried 100 ways to notate paths in php.ini and http.conf: c:, C:, \, \\, /, ". I also installed a new PHP in the root to get rid of the space in the path. It did not help.
When reading dario's comment i stumbeled across him mentioning "path environment variable". I checked that in Window's settings and I realized, that i had added PHP's path to the USER'S path-settings, but not to the SYSTEM'S path. That is why it worked in the command prompt but not when starting Apache as a service. After adding it there it worked fine.

dario at 4assistance dot com

2 years ago

On windows, drop your extension's dependencies into a dir of your choice, but outside of your php install. Add that dir to a path environment variable used by your php. Add <extension_name>.dll to your php's extension_dir, and update your php.ini (unless you're simply testing with php's cli).

ferdnyc at gmail dot com

2 years ago

This is handwaved somewhat in the "Resolving problems" section, but mis-location of (non-extension) DLL files is often a problem when installing PHP extensions on Windows.

Many PHP extensions come with not only the extension DLL, but supplementary DLLs that are required by that extension. (For example, php_luasandbox.dll comes with lua5.1.dll, the lua interpreter it sandboxes.) Those other DLLs should go into the same directory as the php.exe binary, NOT the extension directory.

So, if php_luasandbox.dll is installed at C:\PHP8.1\ext\php_luasandbox.dll, the interpreter would be located at C:\PHP8.1\lua5.1.dll. That allows the PHP binary C:\PHP8.1\php.exe to find those additional DLLs when required.

From Get docs

Jump to:navigation, search

  • « Downloading PECL extensions
  • Compiling shared PECL extensions with the pecl command »

Installing a PHP extension on Windows

On Windows, you have two ways to load a PHP extension: either compile it into PHP, or
load the DLL. Loading a pre-compiled extension is the easiest and preferred way.

To load an extension, you need to have it available as a «.dll» file on your system.
All the extensions are automatically and periodically compiled by the PHP Group
(see next section for the download).

To compile an extension into PHP, please refer to
building from source documentation.

To compile a standalone extension (aka a DLL file), please refer to
building from source documentation. If the DLL file is available neither with your
PHP distribution nor in PECL, you may have to compile it before you can start using the
extension.

Where to find an extension?

PHP extensions are usually called «php_*.dll» (where the star represents the name of
the extension) and they are located under the «PHP\ext» folder.

PHP ships with the extensions most useful to the majority of developers. They are
called «core» extensions.

However, if you need functionality not provided by any core extension, you may still be
able to find one in » PECL. The PHP Extension Community Library (PECL) is a repository for
PHP Extensions, providing a directory of all known extensions and hosting facilities for
downloading and development of PHP extensions.

If you have developed an extension for your own uses, you might want to think about hosting
it on PECL so that others with the same needs can benefit from your time. A nice side effect
is that you give them a good chance to give you feedback, (hopefully) thanks, bug reports
and even fixes/patches. Before you submit your extension for hosting on PECL, please read
» PECL submit.

Which extension to download?

Many times, you will find several versions of each DLL:

  • Different version numbers (at least the first two numbers should match)
  • Different thread safety settings
  • Different processor architecture (x86, x64, …)
  • Different debugging settings
  • etc.

You should keep in mind that your extension settings should match all the
settings of the PHP executable you are using. The following PHP script will
tell you all about your PHP settings:

Or from the command line, run:

drive:\\path\to\php\executable\php.exe -i

Loading an extension

The most common way to load a PHP extension is to include it in your php.ini
configuration file. Please note that many extensions are already present in your
php.ini and that you only need to remove the semicolon to activate them.

Note that, on PHP version 7.2.0 and up, the extension name may be used instead of the extension’s file name. As this is OS-independent and easier, especially for newcomers, it becomes the recommended way of specifying extensions to load. File names remain supported for compatibility with prior versions.

;extension=php_extname.dll
extension=php_extname.dll
; On PHP version 7.2 and up, prefer :
extension=extname
zend_extension=another_extension

However, some web servers are confusing because they do not use the php.ini located alongside
your PHP executable. To find out where your actual php.ini resides, look
for its path in phpinfo():

Configuration File (php.ini) Path  C:\WINDOWS
Loaded Configuration File   C:\Program Files\PHP\5.2\php.ini

After activating an extension, save php.ini, restart the web server and check
phpinfo() again. The new extension should now have its own section.

Resolving problems

If the extension does not appear in phpinfo(), you should check your logs to
learn where the problem comes from.

If you are using PHP from the command line (CLI), the extension loading error can be read
directly on screen.

If you are using PHP with a web server, the location and format of the logs vary depending on
your software. Please read your web server documentation to locate the logs, as it does not
have anything to do with PHP itself.

Common problems are the location of the DLL, the value of the »
extension_dir» setting inside php.ini and compile-time setting mismatches.

If the problem lies in a compile-time setting mismatch, you probably didn’t download the right DLL.
Try downloading again the extension with the right settings. Again, phpinfo()
can be of great help.

Введение в установку PECL

» PECL — это репозиторий расширений PHP, которые доступны вам через систему » PEAR. Эта часть руководства предназначена для демонстрации того, как вы можете получить и установить расширения PECL.

Эти инструкции подразумевают, что /your/phpsrcdir/ является путем к каталогу с дистрибутивом исходного кода PHP, а extname — это имя расширения PECL. Поэтому, приведем в соответствие. Эти инструкции также подразумевают знакомство с » командой pear. Информация в руководстве PEAR для команды pear также применима для команды pecl.

Для того, чтобы расширение можно было использовать, оно должно быть собрано, установлено и загружено. Методы, описанные ниже, предоставляют вам различные рекомендации по поводу того, как собрать и установить расширения, но сами они не будут автоматически загружены. Расширения могут быть загружены через добавление директивы extension в файл php.ini, или путем использования функции dl().

В процессе сборки модулей PHP важно, чтобы у вас были правильные версии необходимых утилит (autoconf, automake, libtool и т.д.). Информацию об этих утилитах и их версиях можно посмотреть тут » Anonymous CVS Instructions.

Загрузка расширений PECL

Есть несколько вариантов для загрузки расширений PECL, в том числе:

  • » http://pecl.php.net/Вебсайт PECL содержит информацию о различных расширениях, которые предоставлены PHP Development Team. Информация, доступная на этом вебсайте, включает в себя: лог изменений, новости релизов, требования и другие подобные детали.
  • pecl download extnameРасширения PECL, которые были опубликованы на сайте PECL, доступны для скачивания и установки через » команду pecl. Также, могут быть также указаны особые ревизии.
  • CVSБольшинство расширений PECL, также, находятся в CVS. Веб-интерфейс для просмотра доступен по адресу » http://cvs.php.net/pecl/. Для загрузки напрямую из CVS используется следующая последовательность команд. Стоит отметить, что пользователь cvsread имеет пароль phpfi:
    $ cvs -d:pserver:cvsread@cvs.php.net:/repository login
    $ cvs -d:pserver:cvsread@cvs.php.net:/repository co pecl/extname
  • Загрузка для Windows Пользователи Windows могут найти скомпилированные расширения PECL путем скачивания Collection of PECL modules со страницы » PHP Downloads, либо через » PECL Snapshot, либо расширения DLL на странице » PECL4WIN. Для компиляции PHP под Windows прочитайте соответствующий раздел
  • PECL для пользователей Windows

    Как и в случае DLL расширения PHP, установка проста и заключается в копировании файла DLL расширения PECL в директориюextension_dir и подключением затем его через php.ini. Например, добавьте следующую строку в ваш php.ini:

    extension=php_extname.dll

    После выполнения этих действий, перезапустите web-сервис.

    Компиляция общих расширений с помощью команды pecl

    PECL позволяет легко создавать общие расширения PHP. Используя » команду pecl, выполните следующее:

    Эта команда загрузит исходный код для расширения extname, скомпилирует и установит extname.so в вашу директорию extension_dir. Файл extname.so может быть затем загружен в php.ini

    По умолчанию, команда pecl не будет устанавливать пакеты, отмеченные состоянием alpha или beta. Если нет доступных стабильных версий пакетов, вы можете установить beta версию пакета, используя следующую команду:

    $ pecl install extname-beta

    Также, вы можете установить определенную версию используя такой вариант:

    $ pecl install extname-0.1

    Замечание: После подключения расширения в php.ini необходимо перезапустить web-сервис для того, чтобы изменения вступили в силу.

    Компиляция общих расширений с помощью phpize

    Иногда, использование инсталятора pecl не подходит. Это может быть связано с тем, что вы находитесь за файерволом или из-за того, что расширение, которое вы хотите установить, недоступно в PECL-совместимом пакете (к примеру, расширения из CVS, которые еще не зарелизены). Если вам необходимо собрать такое расширение, вы можете использовать низкоуровневые утилиты для выполнения сборки вручную.

    Команда phpize используется для подготовки окружения для расширения PHP. В следующем примере директория, где находятся исходные коды расширения, называется extname:

    $ cd extname
    $ phpize
    $ ./configure
    $ make
    # make install

    В случае успешной установки будет создан файл extname.so и помещен в PHP extensions directory. Вам будет необходимо добавить строку extension=extname.so в php.ini перед тем, как вы станете использовать это расширение.

    Если в системе отсутствует phpize, но существует возможность установки заранее скомпилированных пакетов (типа RPM), убедитесь, что установлена соответствующая devel версия пакета PHP, так как они часто содержат команду phpize с подходящими файлами заголовоков для сборки PHP и его расширений.

    Используйте phpize —help для просмотра дополнительной информации.

    Компиляция расширений PECL статически в PHP

    Возможно, вы захотите собрать расширение PECL статично в ваш бинарйный файл PHP. Для этого необходимо поместить код расширения в директорию php-src/ext/ и вызвать перегенерацию конфигурационных скриптов через систему сборки PHP.

    $ cd /your/phpsrcdir/ext
    $ pecl download extname
    $ gzip -d &lt; extname.tgz | tar -xvf -
    $ mv extname-x.x.x extname

    В результате будет создана следующая директория:

        /your/phpsrcdir/ext/extname

    После этого, выполните заново сборку конфигурационного скрипта PHP и затем соберите PHP как обычно:

    $ cd /your/phpsrcdir
    $ rm configure
    $ ./buildconf --force
    $ ./configure --help
    $ ./configure --with-extname --enable-someotherext --with-foobar
    $ make
    $ make install

    Замечание: Для запуска скрипта ‘buildconf’ вам необходимы autoconf версии 2.13 и automake версии 1.4+ (более новые версии autoconf могут работать, но это не поддерживается).

    Одна из двух опций —enable-extname или —with-extname используется в зависимости от расширения. Обычно, в случае, когда расширение не требует подключения внешних библиотек, используется —enable. Для того, чтобы убедиться в этом, выполните следующую команду после buildconf:

    $ ./configure --help | grep extname

    Downloading PECL extensions Compiling shared PECL extensions with PEAR
    Last updated: Tue, 19 Sep 2006

    As with any other PHP extension DLL, installation is as
    simple as copying the PECL extension DLLs into the
    extension_dir folder and loading them from php.ini. For
    example, add the following line to your php.ini:

    extension=php_extname.dll

    After doing this, restart the web server.

    Downloading PECL extensions Compiling shared PECL extensions with PEAR
    Last updated: Tue, 19 Sep 2006

    PHP : Installation and Configuration : Installation of PECL extensions : PECL for Windows users

    As with any other PHP extension DLL, installation is as
    simple as copying the PECL extension DLLs into the
    extension_dir folder and loading them from php.ini. For
    example, add the following line to your php.ini:

    extension=php_extname.dll

    After doing this, restart the web service.

    Code Examples / Notes » install.pecl.windows

    soazine


    When using PHP 5.2.0 within WinXP via Wampserver ( http://www.en.wampserver.com/download.php ) you will find that just simply adding a PECL-based DLL file into php.ini is not enough.  Steps you will have to do to ensure that your PECL extension(s) will be recognized are as follows:
    1) Have the DLL referenced within PHP’s php.ini («extension=[php_name-of-PECL-extension].dll»)
    2) Have the DLL referenced within Windows’ php.ini
    3) Have the DLL within wampserver.ini
    If any of these steps are not included, alongside the obvious web services restart, then PECL is not recognized.

    Понравилась статья? Поделить с друзьями:
    0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии
  • Загрузочный файл windows 10 pro
  • Windows 10 не видит wifi сеть 5 ггц
  • Windows 10 управление устройствами bluetooth
  • С помощью чего происходит управление windows
  • Обновить лицензию windows до professional