Install Mailparse Extension via PECL Without Recompiling PHP

linuxpeclPHP

I am putting this question basically because I want to use PHP: Mailparse extension and stuck in its installation. But, I also want to know some basics of PHP extension installation – Please check bottom – Basic Question regarding extension installation. This may be a silly question but I still have lots of confusion in these things and always get stuck at important times. So please excuse me and help me if you can

I tried the following methods to install Mailparse extension –

Recompiling PHP
I tried to go for recompiling PHP with mailparse extension but I am unable to do that so far – check https://serverfault.com/questions/227976/on-which-location-to-run-configure-while-recompiling-php.

PECL command install
I was thinking since it is a PECL extension, could it be installed through pecl install mailparse command?
On running that command it starts the process –

downloading mailparse-2.1.5.tgz ...
Starting to download mailparse-2.1.5.tgz (37,332 bytes)
..........done: 37,332 bytes
9 source files, building
running: phpize
grep: /opt/lampp/include/php/main/php.h: No such file or directory
grep: /opt/lampp/include/php/Zend/zend_modules.h: No such file or directory

But I finally get this in the end and it fails –

...
...
/tmp/pear/temp/mailparse/php_mailparse.h:113: error: declaration for parameter 'def_charset' but no such parameter
/tmp/pear/temp/mailparse/mailparse.c:1540: error: expected '{' at end of input
make: *** [mailparse.lo] Error 1
ERROR: `make' failed

Downloading mailparse package
Also, they provide mailparse package download option here http://pecl.php.net/package/mailparse. I downloaded it but not sure where to put it and how to install it.

Basic Question regarding extension installation
So, are all these methods of installing an extension valid? If so why do they say in PHP: Mailparse extension that –

In order to use these functions you must compile PHP with mailparse support by using the --enable-mailparse configure option.

Is it because this extension has been moved to the PECL repository. For other PHP extensions which are not moved to PECL repository is it mandatory to recompile PHP?

Thanks

Best Answer

Your best option is to install the PECL package as you were doing, the problem you have there is that you're missing the php headers, they're necessary for any compilation involving php code.

Try downloading the headers (available in the source code package) and copying them were PECL is complaining until you get your PECL module compiled.

Best of lucks! This is an exciting task :)