Installing PHP Enchant using PECL on XAMPP on OS X Lion - php

I am trying to install the PHP enchant library using PECL, but I'm getting "error: Cannot find enchant" even though I have already installed the core enchant executable using Macports. I can even use enchant on the command line. Yet, it seems that PECL cannot find the installation.
During the installation process with PECL, there's an interactive question that appears asking "lib enchant prefix? [shared]", and then waits for my input. I don't really know what this means, but I'm assuming it is asking for the directory where the core enchant executable is installed. In my case, it is in /opt/local/bin. If it asking where the enchant library files are, it is in /opt/local/lib. I have tried to enter both of these paths during this question, and it still produces the same "Cannot find enchant" error.
I don't understand what's going on here. I have PHP 5.3.1, and I am using XAMPP. On the PHP Manual for enchant, it says it comes preinstalled on PHP versions greater than 5.3.0, yet it did not come installed on mine for some reason. Maybe because I installed it via XAMPP?

I had the same issue, use /opt/local as enchant prefix and hopefully it'll work

Related

Compiling php extensions for MAMP

I need to install a couple of PHP extensions, like memcache and geoip, on MAMP 3.5, for PHP 5.6.10.
What I'm doing is to run phpize:
/Applications/MAMP/bin/php/php5.6.10/bin/phpize
Which outputs:
Configuring for:
PHP Api Version: 20131106
Zend Module Api No: 20131226
Zend Extension Api No: 220131226
Then configure:
/configure --with-php-config=/Applications/MAMP/bin/php/php5.6.10/bin/php-config
And, afterwards, try to build with make. This is where I get this error:
/Applications/MAMP/bin/php/php5.6.10/include/php/Zend/zend.h:51:11: fatal error: 'zend_config.h' file not found
I downloaded the content of the include/php folder from php.net, version 5.6.10 (found here).
I feel I'm closer now to solving this problem, but I'm at loss with this error. What am I doing wrong, so that apparently the freshly downloaded php from php.net is missing files?
Thank you.
I ended up using pecl instead of manually compiling the extensions.
The headers missing on the make step were I didn't run ./configure on the php folder - I came across this step by chance, really.
Afterwards, all I had to do was run:
sudo /Applications/MAMP/bin/php/php5.6.10/bin/pecl install memcache
And everything was running on wheels.
Before trying pecl, I tried to run make as I was doing on my post, and the extension compiled successfully, but I had versions mismatch between the php and the extension. I had previously tried pecl without success, but I don't really know what changed in my configuration since I last tried.
Anyway, I wrote a gist with all my steps to get this working, in case anyone has the same problem and is a complete beginner on this subject like I am.

How to install pthreads on a phpfarm php installation

Documenting my struggles to help others and hopefully get some feedback on how I could have done it better.
The command pecl install pthreads fails due to the php installed on my ubuntu 13.04 box not having zts configured.
Options:
1) The ubuntu respository does not have a php package with zts enabled. As of this post, ubuntu only has php 5.4.9 in it's repository (Released: 22 Nov 2012). It is possible to compile a php version from source - which I eventually did (see below), but..
2) I .. ALSO .. wanted to use phpfarm for the ability to run different versions of PHP on my local setup. On github, there is Christian Weiske's original contribution here (phpfarm) and a fork that he has contributed to, by François Poirotte - also called phpfarm. Francois' fork has a few more options to configure ('post-install customization') but I was not able to make that work with a PECL extension. I'm curious to know if misunderstood how to do that, because it looks to me that it just simply does not take PECL commands.
3). Prior to recompiling php from source, I loaded phpfarm (tried both versions), enabled php-fpm (FastCGI) and was able to get my apache2 server to use a phpfarm version (5.5.10) which showed up in a phpinfo() output. But the php-cli always showed the original php version (5.4.9) in the cli (run: php -v). Running (run: php -i | grep php.ini) showed /etc/php5/cli but I had previously removed php5 and aptitude show php5 returned a state of 'not installed.' I even renamed the /etc/php5 directory to see if I could force the system to use the phpfarm php version. Obviously, this is incorrect thinking and I went on to simply compile php 5.6 from source. But, is there something more to do to get a phpfarm php to be used in the cli? I read that the cli loads it's configuration file on a per command basis, unlike the apache2. If I could have run the 5.5.10 version (configured with zts) then I could have then done pecl install pthreads and then re-complied the phpfarm 5.5.10 version with pthreads enabled. Although it appears I will be able to run various versions of php in the apache server, will I ever be able to switch-phpfarm to another version and see it working in the php-cli? Also, I was uncertain on where I could have loaded a pthreads file for the phpfarm compile process to find and use it; could I have done it that way?
4) This stackoverflow post, essentially posted by Joe Watkins - the developer of pThreads is a perfect how-to on getting pThreads installed on a Ubuntu system that has had php configured with zts (Zend Thread Safety). (Thanks Joe!)
A nice tutorial on using phpfarm configured with fast-cgi and the apache server to help run websites under different php configurations.
So what gives with php, php-cli and the phpfarm?
I'm not sure about phpfarm, but do know of another solution ...
Multi
A tool for maintaining multiple installations of PHP in multiple configurations
https://github.com/datingvip/multi
This is a bit more user orientated, will allow you to build many configurations and versions of php, any tagged release of php, and any patched version from any fork of php-src.
In addition, because I wrote it, it will install pthreads for you.
git clone https://github.com/datingvip/multi
cd multi
VERSION=5.5.10 DBG=no-debug ZTS=zts ./php.multi
The above commands will yield an installation of PHP (in one suitable configuration, of one version) in /opt/php.
Look at php.defaults for configuration options and adjust before building
Should configuration fail on, for example, something related to a library like libxml2, it will usually be the case that
sudo apt-get install library-dev
Where library is replaced with the name of the library holding up the build, will fix the problem for you. If it does not, a quick google should get you going again.
Once the build is complete
source /path/to/multi/php.env 5.5.10
Note: multi will always install pthreads for any zts version automatically
I hope that gets you somewhere ...

How to use Pthreads PHP extension in Ubuntu

I have problems with the Pthreads PHP extension. I have compiled PHP with ZTS enabled (--enable-maintainer-zts) and installed the pthreads via pecl and also tried to manually compile the extension.
It seems I don't actually know how to use it. I assumed I would be able to use the Thread class in PHP like any other built-in class, but with no luck as PHP doesn't recognize it. POSIX functions seem to work.
I am using Ubuntu 12.10 Server 64-bit with mod_php 5.4.6.
If you cannot access the extensions classes then it is not loaded.
I think you opened a bug report, to which I responded that your configure line is malformed.
The configure line you want to use is:
./configure --enable-pthreads --enable-maintainer-zts
The above command will build pthreads as a DSO.
./configure --enable-pthreads=static --enable-maintainer-zts
The above command will build pthreads statically into PHP.
Both are equally supported by 5.3, 5.4 and even 5.5.
Additionally, if you are overwriting your system installation then you should use a specific --prefix, for example, if you php executable is at /usr/bin ( which you can ascertain with "which php" ), then --prefix=/usr will overwrite your system installation.
Clean out your old installations ( do make uninstall if the sources are still available ). Start again, ensure you are either, overwriting the system installation or isolating this one completely.
Please update the bug report when you have worked it out.

Using PECL to install extensions on Windows 7

I've been trying to install some PECL extensions on my laptop, but I've ran into a few problems. Whenever I run pecl install whatever from the command line I get a message saying ".\php.exe appears to have a suffix .exe, but config variable php". It seems like PECL is using PEAR to perform installations. I checked and php_suffix is located in the files PEAR_Config.php and PEAR_Builder.php, but I'm not sure what to do with it in there.
Any ideas on how to fix this or workarounds? Unfortunately the pecl4win seems to be down, and http://downloads.php.net/pierre/ the site I usually go to for the .dll's has outdated versions for the version of PHP I'm using (5.3.1).
Unfortunately I don't know the specifics, but at least I can point you in the right direction To use pecl on windows, you need to setup Visual Studio c/c++ or MingW32 c/c++ and then configure pecl to use either compiler for building the requested extensions.
Unlike pear packages, pecl packages are PHP c extensions that needed to be compiled against your local PHP install.
Update
https://wiki.php.net/internals/windows/stepbystepbuild A mostly friendly wiki page on setting up a windows box for building PHP from source. Looks like you need to build the interpreter and support libraries before you can get pecl working.

Configuring already installed PHP to work with already installed ncurses (MAMP)

I have installed MAMP and the PHP it came with wasn't compiled with ncurses. I've tried to use port to install ncurses and it seems that it already exists on my system so now I was wondering if there was a way to get PHP to use it without having to recompile PHP --with-ncurses.
In other words: Can PHP be configured to use ncurses without the recompilation?
I'm sorry for the late answer but this can actually be done quite easily with MAMP.
I have done this on my MacBook running OS X Snow Leopard.
Your MAMP directory contains the tar file of the php source code. MAMP version 1.8.4 ships with php-5.2.11.tar located here: /Applications/MAMP/bin/php5/
cd /Applications/MAMP/bin/php5/
tar -xvf php-5.2.11.tar
cd php-5.2.11/ext/ncurses
/Applications/MAMP/bin/php5/bin/phpize
./configure --with-php-config=/Applications/MAMP/bin/php5/bin/php-config
make
make install
Afterwards you just need to add the ncurses.so extension to the MAMP php.ini
echo "extension=ncurses.so" >> /Applications/MAMP/conf/php5/php.ini
php -i | grep ncurses
This gives me:
ncurses
ncurses support => enabled
ncurses library version => 5.7
You can also do this with the PCNTL extension ;) ;)
Cheers!
According to the manual, ncurses must be compiled in. Some extensions can be compiled as shared libraries (dll/so) and loaded dynamically, but some can't. Seems that ncurses can't.
I don't know a lot about how mac packages are structured, but isn't it a bsd/ports style installation? In that case, just find the package and configure + recompile it.
Edit: I see that mamp is a binary distribution. You're out of luck then. I would suggest that you install at least php from sources. It's very useful to be able to install new extensions etc. It's fairly straight forward to compile php, so even if you aren't completely confident with compiling stuff, you should be able to huddle through it.

Categories