How to build SQL Relay for PDO from source on windows? - php

I am trying to integrate SQL Relay with PHP PDO on Windows (WAMP). I have installed and compiled Rudiments and SQL Relay on Windows through Visual Studio Developer Command Prompt following the instructions given on the Rudiments and SQL Relay SourceForge pages.
Then I downloaded the pdo_sqlrelay extension source from github and tried to build the dll for this extension.
In the build instructions, I couldn't find the ones pertaining to Windows specifically. I found instructions related to Linux. They are:
cd /path/to/pdo_sqlrelay
phpize
./configure --with-php-config=/path/to/php-config \
--with-pdo-sqlrelay=/path/to/sqlrelay/prefix \
--with-rudiments=/path/to/rudiments/prefix
make
make install
I tried to convert them to the relative Windows commands by following the step by step php extension build instructions on PHP's Wiki for building for Windows.
When I tried to execute the command, it threw a fatal error. (like undefined or invalid $remains).:
configure --disable-all --enable-cli --enable-$remains
I would appreciate if someone could help me out to build the pdo_sqlrelay extension on Windows.

you need to ...
first run bin\phpsdk_setvars.bat
to set up the build environment, so that $remains will be known as a variable.
then configure the build with buildconf (or buildconf --force for rebuilding).
then configure --disable-all --enable-cli --enable-$remains ... you probably might also want to --disable-zts (depending which PHP is being used).
it's rather nmake to build & nmake clean to clean.
to install & uninstall it's nmake install and nmake uninstall.
the documentation also states ...that:
First build and install Rudiments, then build and install SQL Relay.

Related

"mysql_config not found" when trying to install PHP 7.2 from sources

On Ubuntu, I've got currently installed from sources Apache 2.2.32 + PHP 5.4.45 + mySQL 5.1.55. And now, I want to install PHP 7.2.16.
I downloaded the .tar.gz file, and tried to do the 'configure' of PHP:
sudo ./configure --prefix=/usr/local/php_7.2.16 --with-apxs2=/usr/local/apache2/bin/apxs --with-mysqli=/usr/local/mysql --with-gettext --with-curl
(it worked with PHP 5.4, with another directory, obviously)
However, I get now the following error message:
mysql_config not found
configure: error: Please reinstall the mysql distribution
Must I reinstall the mySQL from scratch or is there any workaround to avoid this? Thank you.
The mysql_config is installed via mysql-devel. If you run the mysql_config it should return to you all the options for compiling clients. If you install it from package, it should be somewhere like /usr/bin/mysql_config.
And when source compiling php you can pass the path of mysql_config under
--with-mysqli=/usr/bin/mysql_config

Cassandra php driver on MacOS - Class 'Cassandra\SimpleStatement' not found

Good day, everyone.
Usually I just using this Official Docs in *nix OS
But now i'm using MacOs and this instructions just doesn't work properly.
In case of pecl install cassandra I got this message:
checking for supported DataStax C/C++ driver version... awk: can't open file /include/cassandra.h
source line number 1
configure: error: not supported. Driver version 2.4.2+ required (found )
ERROR: `/private/tmp/pear/install/cassandra/configure --with-php-config=/usr/bin/php-config' failed
My logic tell me that in that case I need make DataStax C/C++ driver by my own. In folder php-driver\lib I deleting cpp-driver and using this instruction make new and fresh C/C++ driver without errors.
So in official doc it says:
Note The install.sh script will also compile and statically link into the extension a submoduled version of the DataStax C/C++ driver for Apache Cassandra. To use a version of cpp driver that you already have on your system, run phpize, ./configure and make install.
But when i trying to run ./configure from php-drive/ext I got almost the same error:
checking for supported DataStax C/C++ driver version... awk: can't open file /include/cassandra.h
source line number 1
configure: error: not supported. Driver version 2.4.2+ required (found )
Even if I continue and after that error run make install it gives me that log:
/bin/sh /Users/antvirgeo/php-driver/ext/libtool --mode=install cp ./cassandra.la /Users/antvirgeo/php-driver/ext/modules
cp ./.libs/cassandra.so /Users/antvirgeo/php-driver/ext/modules/cassandra.so
cp ./.libs/cassandra.lai /Users/antvirgeo/php-driver/ext/modules/cassandra.la
----------------------------------------------------------------------
Libraries have been installed in:
/Users/antvirgeo/php-driver/ext/modules
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `DYLD_LIBRARY_PATH' environment variable
during execution
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Installing shared extensions: /usr/lib/php/extensions/no-debug-non-zts-20121212/
cp: /usr/lib/php/extensions/no-debug-non-zts-20121212/#INST#24727#: Operation not permitted
make: *** [install-modules] Error 1
Libraries have been installed in:
/Users/antvirgeo/php-driver/ext/modules
Even if I adding cassandra extension with that path to php.ini I still got error Class 'Cassandra\SimpleStatement' not found in my project.
php -d="extension=modules/cassandra.so" -m showing that cassandra in list of PHP Modules
What am I doing wrong?
PS: I have ubuntu OS in Parallels with this project with DataStax php driver installed with this instructions works fine.
____upd:
After all instructions of #Fero without ANY ERRORS, command /usr/local/bin/php -i | grep -A 10 "^cassandra$" showing me this:
cassandra
Cassandra support => enabled
C/C++ driver version => 2.4.2
Persistent Clusters => 0
Persistent Sessions => 0
Directive => Local Value => Master Value
cassandra.log => cassandra.log => cassandra.log
cassandra.log_level => ERROR => ERROR
And still the same error - Class 'Cassandra\SimpleStatement' not found
______________UPDATED LAST:
Aaaaand it's working! I wrote output phpinfo(); in my project and realize that apache using other php version and php.ini, where wasn't extension=cassandra.so at all.
You will need to install the DataStax C/C++ driver which is a dependency of the PHP driver. Using these instructions followed by make install after the driver has been successfully built will ensure this dependency is available when building the PHP driver. Using the PHP driver build instructions you will need to make sure that GMP and PHP dev libraries are also available before running pecl install cassandra.
EDIT:
Since you are using El Capitan you are running into issues with the System Integrity Protection and you will need to disable it in order to copy files into /usr. The better and recommended option is to install PHP using Homebrew; however you can also use MacPorts if preferred.
Below are the steps used to reproduce the installation of the PHP driver on a clean OSX El Capitan image with Xcode and Homebrew already installed:
brew install autoconf cmake libuv gmp openssl pcre homebrew/php/php55
brew link homebrew/php/php55
mkdir code
pushd code
git clone https://github.com/datastax/php-driver.git
pushd php-driver
git submodule update --init --recursive
pushd lib/cpp-driver
mkdir build
pushd build
cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl ..
make -j$(sysctl -n hw.ncpu)
sudo make install
popd
popd
mkdir build
pushd ext
/usr/local/bin/phpize
popd
pushd build
../ext/configure --with-php-config=/usr/local/bin/php-config
make -j$(sysctl -n hw.ncpu)
sudo make install
popd
popd
sudo sh -c 'echo "extension=cassandra.so" >> /usr/local/etc/php/5.5/php.ini'
You can then verify the installation using the following command:
/usr/local/bin/php -i | grep -A 10 "^cassandra$"
NOTE: PHP v5.5 is utilized above since that is the default version that comes with El Capitan; PHP v5.6 and v7.0 can also be used instead.
If you need to install the Cassandra PHP extension on MacOS, you can do this simply by installing it via PECL, without having to do anything with turning on or off System Integrity Protection. I've written a blog post with easy step-by-step instructions. It also includes a link to installing PHP from Homebrew since they removed the Homebrew/php tap back in April of this year.
It also by passes the incorrect instructions given on the DataStax website. In short ...
Install Dependencies (I run these commands one at a time to easily view any messages):
$ brew install autoconf
$ brew install cmake
$ brew install automake
$ brew install libtool
$ brew install gmp
$ brew install libuv
$ brew install openssl
Retrieve and build the C++ driver and then create a build directory inside the cpp-driver folder:
$ git clone https://github.com/datastax/cpp-driver.git --depth=1
$ mkdir cpp-driver/build
$ cd cpp-driver/build
Make and build the driver with a qualified call to OpenSSL:
$ cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/ -DOPENSSL_LIBRARIES=/usr/local/opt/openssl/lib ..
$ make
$ make install
Now you're good to go to install the Cassandra PHP extension libraries using PECL:
$ pecl install cassandra
Check to make sure that the Cassandra extension was added to your PHP.ini file. If not add it.
[cassandra]
extension="cassandra.so"
Restart Apache and you're off and running with Cassandra in PHP.
If you want more detail on what's happening in the above instructions, refer to my blog post here:
https://medium.com/#crmcmullen/how-to-install-the-cassandra-php-driver-on-macos-10-13-high-sierra-and-10-14-mojave-c18263831ccb

How do I enable --enable-soap in php on linux?

That's much the question. I have PHP 5.2.9 on Apache and I cannot upgrade PHP. Is there a way for me to enable SOAP in PHP 5.2.9? The PHP manual did not help at all when it said, "To enable SOAP support, configure PHP with --enable-soap ." How do I configure?
Getting SOAP working usually does not require compiling PHP from source. I would recommend trying that only as a last option.
For good measure, check to see what your phpinfo says, if anything, about SOAP extensions:
$ php -i | grep -i soap
to ensure that it is the PHP extension that is missing.
Assuming you do not see anything about SOAP in the phpinfo, see what PHP SOAP packages might be available to you.
In Ubuntu/Debian you can search with:
$ apt-cache search php | grep -i soap
or in RHEL/Fedora you can search with:
$ yum search php | grep -i soap
There are usually two PHP SOAP packages available to you, usually php-soap and php-nusoap. php-soap is typically what you get with configuring PHP with --enable-soap.
In Ubuntu/Debian you can install with:
$ sudo apt-get install php-soap
Or in RHEL/Fedora you can install with:
$ sudo yum install php-soap
After the installation, you might need to place an ini file and restart Apache.
In case that you have Ubuntu in your machine, the following steps will help you:
Check first in your php testing file if you have soap (client / server)or not by using phpinfo(); and check results in the browser.
In case that you have it, it will seems like the following image ( If not go to step 2 ):
Open your terminal and paste: sudo apt-get install php-soap.
Restart your apache2 server in terminal : service apache2 restart.
To check use your php test file again to be seems like mine in step 1.
As far as your question goes: no, if activating from .ini is not enough and you can't upgrade PHP, there's not much you can do. Some modules, but not all, can be added without recompilation (zypper install php5-soap, yum install php-soap). If it is not enough, try installing some PEAR class for interpreted SOAP support (NuSOAP, etc.).
In general, the double-dash --switches are designed to be used when recompiling PHP from scratch.
You would download the PHP source package (as a compressed .tgz tarball, say), expand it somewhere and then, e.g. under Linux, run the configure script
./configure --prefix ...
The configure command used by your PHP may be shown with phpinfo(). Repeating it identical should give you an exact copy of the PHP you now have installed. Adding --enable-soap will then enable SOAP in addition to everything else.
That said, if you aren't familiar with PHP recompilation, don't do it. It also requires several ancillary libraries that you might, or might not, have available - freetype, gd, libjpeg, XML, expat, and so on and so forth (it's not enough they are installed; they must be a developer version, i.e. with headers and so on; in most distributions, having libjpeg installed might not be enough, and you might need libjpeg-dev also).
I have to keep a separate virtual machine with everything installed for my recompilation purposes.

Upgrade to PHP 5.4 on MAC and remove version 5.3.10

I would tring to update my php version to the version 5.4.
When I'm looking via /usr/local/bin/php -v in the console I see the version 5.4.3 and with php -v it tell me there is the version 5.3.10 installed.
How can I remove the older version?
Update:
As of early 2014, you are probably better of installing from http://php-osx.liip.ch/ builds as it contains most extensions. In case you really do need to compile your own, follow the original answer.
Original answer:
Mac comes with a preinstalled php you can easily overwrite.
This is a list of steps I take to update the php I have installed:
Prerequisites:
Xcode and it's Command line utilities (install form preferences) will give you a gcc compiler to build the php with
libjpeg, libpng etc. if you want to build with these.
Building and installing php:
Download the distribution from www.php.net/downloads.php
Untar the archive and point your console into the location
Now, having still the original old php installed, run php -i | head in the console. What you want is to configure your new php with these flags to ensure you have proper pcre support and everything works just fine.
In the php source directory you untarred, run the ./configure script with the flags you just got
Build php by running make and sudo make install afterwards. That will actually replace the original php distributed with OS X.
And dont forget to run make test...
Ex.: my workflow for building php
wget http://url_to/php_source.tar.gz
tar -zxvf php_source.tar.gz
cd php_source/
php -i | head
./configure --prefix=/usr --with-snmp # ... same flags as previous build
make
sudo make install

PDO MySQL Driver on Mac

I have a mac with a custom PHP 5 install that built from about a year ago. I remember it took all Sunday and I had to compile about 20 times to get it right. The MySQL I have is from entropy and was precompiled.
Now I need to get PDO with the MySQL driver working and the driver is not installed. I tried the "pecl install pdo_mysql" and it dies at a point where it can't find some mysql files. Any ideas how I can fix this quickly?
checking for mysql_config... not found
configure: error: Cannot find MySQL header files under
ERROR: `/private/tmp/pear/temp/PDO_MYSQL/configure' failed
I'll post whatever paths or messages you need to help me troubleshoot this. Will I have to compile PHP all over again, or can I just compile the pdo_mysql extension?
I hope I don't seem lazy, I just have a lot of code to write and not a lot of time to fight with my PHP configuration.
You're going to need to compile it by hand, instead of via PECL. You'll need to know where your MySQL install is. I don’t know about the Entropy packages, but the builds provided by MySQL (which I recommend) install into /usr/local/mysql.
$ pecl download pdo_mysql
$ tar xzf PDO_MYSQL-1.0.2.tgz
$ cd PDO_MYSQL-1.0.2
$ phpize
$ ./configure --with-pdo-mysql=/usr/local/mysql
$ make && sudo make install
And that should get you to the point where you can configure it.
FYI; the MySQL PDO driver is included in the php 5.2.9 and 5.3 builds from Marc Liyanage's entropy.ch

Categories