I try to make a custom php extension for code Encryption purposes,
I followed this tutorial to make an custom extension: How to make a PHP extension
i get this warning when compiling the extension:
WARNING
The following arguments is invalid, and therefore ignored:
--enable-php-helloworld
i did all according to the tutorial, i build on windows.
what are possible things i do wrong.
I followed that section: https://stackoverflow.com/a/32575493/3103078
I replicated the code 1:1 (Os: Windows)
used commands:
phpize
configure --enable-php-helloworld
nmake
php -d extension=php_helloworld.so --re php_helloworld
Expected result:
>>>helloworld support
Actual Result:
>>>
reproduction:
mkdir php
start https://altushost-swe.dl.sourceforge.net/project/winflexbison/win_flex_bison3-latest.zip
set path=%path%;C:\your_path\to\bison
start https://altushost-swe.dl.sourceforge.net/project/gnuwin32/sed/4.2.1/sed-4.2.1-bin.zip
set path=%path%;C:\your_path\to\sed
start https://codeload.github.com/skvadrik/re2c/zip/refs/tags/2.1.1
set path=%path%;C:\your_path\to\re2c
start https://download.microsoft.com/download/5/C/3/5C3770A3-12B4-4DB4-BAE7-99C624EB32AD/windowssdk/winsdksetup.exe
rem after install
set path=%path%;C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x64
start https://windows.php.net/downloads/releases/php-devel-pack-7.3.29-Win32-VC15-x64.zip
rem install upper in php dir
phpize
configure --enable-php-helloworld
nmake
php -d extension=php_helloworld.so --re php_helloworld
The issue was not utilizing the php-src inside the sdk.
Also, on windows you need to use php-sdk-binary-tools, else it wont work when you compile it.
I'll do a tutorial on this soon.
Related
I built a number of custom PHP extensions under windows 8-10 years ago. I made the move to Ubuntu Linux for all of my web stuff some years ago and find I need to create another custom extension. I'll be doing the development under Ubuntu this time.
I've created a very simple extension (a no-op actually) just to make sure I have the build process working. It's not.
Here is what I have done:
Cloned PHP from Git
Checked out PHP-5.5
Configured with --disable-all --enable-debug --enable-maintainer-zts \
--prefix=
Build PHP
Success php -i shows:
Zend Extension Build => API220121212,TS,debug
PHP Extension Build => API20121212,TS,debug
Created ext/a1 for my new, very simple extension
Created the basic extension (from Sara Goleman's book)
Ran phpize in ext/a1
Ran ./configure --enable-a1
Ran make
Build was successful.
Copied a1.so to the extensions directory
phpdir/bin/php -dextension=a1.so -v
Fails. Results in:
Module compiled with build ID=API20121212,NTS
PHP compiled with build ID=API20121212,TS,debug
So. Color me confused. According to what I've read, the phpize command is supposed to match the extension build settings to the php build settings.
I've apparently missed something basic here somewhere.
Help will be most appreciated.
Its hard to say what exactly was going wrong, I can only say that the extension was build using a different config than the php version.
I will describe some reproducible steps how to compile a most basic extension with debug symbols within the PHP source folder. The extension contains no code except of some boilerplate code created by ext_skel. It just describes the compilation process on UNIX. It is a shell script, you might execute it.
#!/bin/sh
# Should work for all PHP5 versions
VERSION="5.6.9"
# Download the PHP source code
wget \
--continue "http://de2.php.net/get/php-$VERSION.tar.gz/from/this/mirror" \
-O "php-$VERSION".tar.gz
tar xf "php-$VERSION.tar.gz" && cd "php-$VERSION/ext"
# Create a hello extension from skeletons
./ext_skel --extname="hello"
# Uncomment two lines in ext/hello/config.m4
# Read the comments there and you'll know what I'm doing
sed -ri.original \
-e 's/(dnl )(PHP_ARG_ENABLE\(hello)/\2/' \
-e 's/(dnl )(\[ --enable-hello)/\2/' \
hello/config.m4
# Build PHP and the extension
cd ..
./buildconf --force
./configure \
--enable-debug --enable-maintainer-zts \
--enable-hello=shared
make -j
# Test if it is working
sapi/cli/php \
-dextension=modules/hello.so \
-r 'var_dump(extension_loaded("hello"));'
You can now start to enter code to ext/hello/hello.c and create your extension. If you want to compile the changes you make just issue make without arguments.
Since we've compiled using --debug we you can now use gdb to debug the C code and explore how PHP internally works. To start a debugging session use:
gdb sapi/cli/php
...
(gdb) break main
(gdb) run -dextension=modules/hello.so some.php
Of course you'll mostly set breakpoints into your extension functions rather than in the php main() function once you've added code to the extension. However, this should show the basic steps to get there.
Have fun! :)
gdb
I have PHP 5.4.26 (FreeBSD); I am trying to use the old MySQL libraries.
Saw this command:
./configure --with-mysql=/path/to/mysql_config
Where do I put this command; it says that it is a compile time decision?
Note you'll need root privileges to do this. Download the source code from php.net. unzip it to a folder.
On a command line in the unzip folder:
./configure --with-mysql=/path/to/mysql_config
make
make test
make install
That will replace your current installation. Note that you will need to carefully research the configure options you want so you don't lose any functionality you currently have.
Just to be complete, here is a tutorial for FreeBSD for using the old libraries and the new ones. Since they are separate.
Using “new” PHP with “old” MySQL passwords
Just in case that page disappears here are the steps for FreeBSD:
# pkg_delete php5-mysql
# cd /usr/ports/databases/php5-mysql
# make config (uncheck support for mysqlnd)
# make install clean
I'm compiling PHP-CPP source but i getting error in Windows 7.But, in Linux (for .so extension) it works fine. The error given by the compiler is:
collect2.exe [Error] ld returned 1 exit status
Note: I'm using PHP-CPP not PHP source code directly...
Error: mkdir -p shared/common The syntax of the command is incorrect.
Makefile:190: recipe for target 'shared_directories' failed
mingw32-make: *** [shared_directories] Error 1
PHP-CPP (i'm using)
Error Image
So, you are using MinGW (mingw32-make) in a cmd.exe hosted environment; cmd.exe's mkdir (md) command doesn't offer a -p option, AFAIK. Your makefile appears to expect a POSIX shell hosted environment, so you may have better luck with such, (e.g. the bash shell furnished by MinGW.org's MSYS, or by Cygwin).
You have to download the newest release of phpcpp - then make a build with cmake (just use the cmake gui for windows) - here it's important to set the follwoing entries for build:
PHPCPP_ARCH with "x86_64" and
PHPCPP_PHP_PATH to the path where your root dir of the php source is ...
if you want to build for static libs - set this:
PHPCPP_MSVCRT_STATIC
if you want to have a dynamic build just don't set this Entry ...
Now just click on "Configure" - when its completed just hit "Generate" ..
if all works fine you can now click on "Open Project" and usualy now Visual Studio will load the data needed for compiling ...
Now just compile and now you can use .lib / .dll for further implementations ...
beginner with linux here but I am trying to follow some simple instructions for setting up a riak-php-client that will enable me to make my riak database and website communicate, i.e. fetch and display data to the website. The github repository of which I'm following:
https://github.com/basho/riak-php-client
I clone the repository, but at "Quick start" when trying to run
user#user-pc:~/riak-php-client $ ./config --with-curl
I end up getting the message "bash: ./config: No such file or directory", same story when I'm in home/riak-php-client/src. Any ideas on how to fix this?
The instruction to run
./configure --with-curl
is intended to show you how to enable curl in your local build of PHP, when compiling PHP from source. The readme doesn't make that very clear.
The command
php -m | grep curl
will return 'curl' if your local PHP installation has curl enabled, if it is, just continue on with the examples in the readme. If not there are other questions on stack overflow like this one that may help
I am trying to run the 'phpize' command on MacOSx Mountain Lion, but this is what I get:
Cannot find config.m4.
Make sure that you run '/opt/local/bin/phpize' in the top level source directory of the module
How do I resolve this error ?
The phpize command is meant to be run at the top level of an extension source dir (this source dir should contain a file name config.m4).
See http://php.net/manual/en/install.pecl.phpize.php for more information.
In plain English, it means you're running the command from the wrong directory. You need to be in the directory that contains the source for the extension you're trying to install.
For example, if you're trying to install mcrypt, like I was when I came across this stack overflow page, you need to be in php-5.6.24/ext/mcrypt and then run the command.
My problem was that I was trying to execute the command just to see if I had it installed.
Trying to execute the command alone gives you that error, only use it inside the directory (most likely you downloaded) that contains the extension that you're trying to install.
Here some instructions to install Xdebug for php7.2 for example.
Take special care in step 3 and 4, first you change dir to the unpacked downloaded extension and then you run phpize.
http://qiita.com/MasatoYoshioka#github/items/e542f39a6f1a3bc1f71e
In terminal
ls config.m4
ls config*
config.w32 config0.m4
cp config0.m4 config.m4
cd /usr/local/src/php-5.3.29/ext/zlib
phpize
./configure
make clean && make && make install
nano php.ini
add extension=zlib.so
got inside the xdebug folder than try to run the phpize
Sometimes, using the pecl installer is not an option. This could be because you're behind a firewall, or it could be because the extension you want to install is not available as a PECL compatible package, such as unreleased extensions from git. If you need to build such an extension, you can use the lower-level build tools to perform the build manually.
The phpize command is used to prepare the build environment for a PHP extension. In the following sample, the sources for an extension are in a directory named extname:
$ cd extname
$ phpize
$ ./configure
$ make
# make install
first run ./configure it will create config.m4 file, rest the steps are same