You want to install a PECL package; this builds a PHP extension written in C to use inside PHP.
Make sure you have all the necessary extension libraries and then use the PEAR installer bundled command pecl:
% pecl install mailparse
To use the extension from PHP, add the appropriate line to your php.ini file:
The frontend process for installing PECL packages is just like installing PEAR packages for code written in PHP. However, the behind-the-scenes tasks are very different. Because PECL extensions are written in C, the installer needs to compile the extension and configure it to work with the installed version of PHP. As a result, at present, you can build PECL packages on Unix machines if you have the necessary development tools installed and on Windows machines if you use MSDev.
Unlike PHP-based PEAR packages, PECL extensions don't automatically inform you when you lack a library necessary to compile the extension. Instead, you are responsible for correctly preinstalling these files. If you are having trouble getting a PECL extension to build, check the README file and the other documentation that comes with the package. The installer puts these files inside the docs directory under your PEAR hierarchy.
When you install a PECL extension, the pecl command downloads the distribution file, extracts it, runs phpize to configure the extension for the version of PHP installed on the machine, and then makes and installs the extension. It may also prompt you for the location of libraries:
% pecl install mailparse downloading mailparse-2.1.1.tgz ... Starting to download mailparse-2.1.1.tgz (35,883 bytes) ..........done: 35,883 bytes 9 source files, building running: phpize Configuring for: PHP Api Version: 20031224 Zend Module Api No: 20041030 Zend Extension Api No: 220040412 ... Build complete. (It is safe to ignore warnings about tempnam and tmpnam). running: make INSTALL_ROOT="/var/tmp/pear-build-root/install-mailparse-2.1.1" install Installing shared extensions: /var/tmp/pear-build-root/install-mailparse-2.1.1/usr/lib/php/20041030/ running: find "/var/tmp/pear-build-root/install-mailparse-2.1.1" -ls 8306920 4 drwxr-xr-x 3 root root 4096 May 1 16:40 /var/tmp/pear-build-root
PECL extensions are stored in different places than PEAR packages written in PHP. If you want to run pecl, you must be able to write inside the PHP extensions directory. Because of this, you may want to install these packages while running as the same user you used to install PHP. Also, check the execute permissions of these files; because most PEAR files aren't executable, your umask may not provide those executable files with the correct set of permissions.
If you're running PHP and PECL in a Windows environment, you may prefer to download precompiled DLLs for the PECL extensions you need from http://pecl4win.php.net/.
PHP's dl( ) can be used to load extensions at runtime, but it is deprecated. If possible, activate new extensions in the php.ini file.
26.7.4. See Also
13.12 for information on installing PEAR packages; Recipe 26.5 for more on upgrading an existing package; Recipe 26.6 to uninstall a package; the PECL Windows Repository at http://pecl4win.php.net .