Using PECL to install extensions on Windows 7 - php

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.

Related

Using libsodium in PHP 7.2

In PHP 7.2 libsodium should be part of PHP core. Is any entry in php.ini file required to make it work or maybe it should work out of the box?
I'm trying with PHP Version 7.2.0beta2 and functions like sodium_version_string() or sodium_compare are unknown. I'm using PHP docker box (7.2-rc-fpm)
Just in case - I haven't installed any PECL extension because as far as I understand it shouldn't be necessary.
In order for this extension to be built, the library has to be present, as long as the development headers.
In addition, the --with-sodium option has to be given to the ./configure script before compiling PHP.
If you don't want to recompile PHP, you can install the PECL version, which offers the exact same API (I usually update the PECL version first, and then port the changes to the PHP source code).

php pecl extension - compiling for win 8.1

I would like to compile the php pecl extension ev http://pecl.php.net/package/ev for PHP 5.5+ into a dll-file on Win 8.1 64-Bit.
I have already downloaded the ev source-code and already installed Visual Studio Express(!) 2012. What do i have to do next? How can i compile the source-code?
There is no file->new->project from existing code in Visual Studio Express(!).
I have also already tried to install the pecl exptension with the pecl command. But this doesn´t work:
C:\xampp\php>pecl install ev No releases available for package
"pecl.php.net/ev" install failed
Check install.md file there are all informations what you need.
To be honest you can't install it doing with pecl command because there is information:
Currently GNU/Linux platforms supported only.
There is also manual installation guide but probably you would need to do it with MinGW/MySYS if any. I suppose you would need to edit sources.
mingw-w64 project has replaced mingw and mingw-build.
https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/4.9.1/threads-posix/sjlj/
https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/4.9.1/threads-posix/sjlj/
you can of course pick a different version number by going up to a parent dir in the file tree. for example, if you look in the personal builds, you would find the most up-to-date:
https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/dongsheng-daily/4.9/
gcc uses not .lib files but instead .a files for libs, and php includes a .lib for devs, so immediately I know it's for VC++ (and it was compiled with that and it says so for the windows target download).
after you have correctly configured MSYS (not an easy job),
./configure;make;make install
./configure gives me the error:
configure: error: xml2-config not found. Please check your libxml2 installation.
libxml2 requires python, which certain windows antivirus packages remove from mingw-w64.

How to install mcrypt on OS X's natively installed PHP?

I am trying to install the mcrypt PHP extension on my OS X Mountain Lion 10.8 operating system. This OS comes shipped with Apache and PHP already installed. The mcrypt extension however does not come shipped with PHP. I want to install mcrypt into the version of PHP that came shipped with my machine.
I do not want to use Homebrew, Macports, or any similar package manager, and I do not want to install another version of PHP in addition to the one I already have. I just want to plug mcrypt into the PHP that came bunded with my OS. I feel like this makes sense, instead of having multiple versions of the same program installed, yet every tutorial I come across seems to all immediately say to use Homebrew/Macports, and the few that don't teach you how to install a new PHP instead of using the one I already have.
I started following the directions laid out on this page: http://www.coolestguyplanettech.com/how-to-install-mcrypt-for-php-on-mac-osx-lion-10-7-development-server/.
I downloaded libmcrypt-2.5.8.tar.gz from Sourceforge.
I extracted the contents with the following command: tar -zxvf libmcrypt-2.5.8.tar.gz.
I entered the libmcrypt-2.5.8 directory that was created and issued the following commands: ./configure, make, and sudo make install.
Now that tutorial says to go into a directory that was created by a new, non-native version of PHP that the tutorial tells you to install, not the native version that came shipped with OS X. The tutorial says to go into the following directory: cd ../php-5.3.13/ext/mcrypt/ (which is a directory I don't have), and run the phpize command. I can't go into that directory because I'm using the native PHP that came with OS X, so instead I go into the libmcrypt-2.5.8 directory, but when I try to run the phpize command I get an error that says: Cannot find config.m4. Make sure that you run '/usr/bin/phpize' in the top level source directory of the module. I do however have the files acinclude.m4 and aclocal.m4 in this directory. I am not sure if they are related to the config.m4 that phpize is looking for.
I am not sure how to proceed. Maybe I should just cut my losses and install another PHP using Macports or Homebrew, but I'd really prefer to use the native PHP that came bundled with OS X. Can you help me figure out how to do this? It would really help me a lot, and help me understand better how PHP and extensions work. Thank you!
"I'd really prefer to use the native PHP that came bundled with OS X.
Can you help me figure out how to do this? It would really help me a
lot, and help me understand better how PHP and extensions work."
The PHP that came bundled with OSX isn't any more "Native" than any other version that you would install.
You don't have that directory because, IIRC, OSX doesn't ship with PHP source, just a compiled binary and apache module.
You can only run phpize on a php extension, which you can get in the PHP source download (including the mcrypt extension). What you downloaded is the C library (which you may also need to install) that the PHP extension will reference (you don't need to worry about how this happens).
If you want to just install that extension:
Download it
Extract and cd into
sudo phpize
sudo ./configure && sudo make && sudo make install
Add extension=mcrypt.so (or whatever is generated) to your php config / php.ini and restart apache
This sounds to me like a good opportunity to learn more about how your computer works. This is some documentation I wrote for myself a few years ago on how to do this:
http://www.calvinfroedge.com/common-php-compile-configuration-options/ (note that the formatting in the blog might not work if you paste it into terminal, for example –with-mysql should be --with-mysql)
Besides, you don't need to get rid of your PHP installation that came with OSX. You can download the PHP source to a brand new directory, compile it, backup the old binary, and either symlink the result of 'which php' to your new installation or add the binaries that get generated after you compile to your source.

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.

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