how to add extension in php Opensuse - php

I want to add an extension so I can use my own function in php for example my codes of C but I don't know the requisites and instructions of doing it.I have php5 and OS:Opensuse 11.
I don't know about configure and the codes in shell
there should be something like ext_skel so I can create config files but I don't have it should I download it from somewhere?
Due to this link http://www.tuxradar.com/practicalphp/20/3/0
there should be ext directory but I don't have it.
Thanks in Advance
cd
vi ext/util/config.m4a
./build conf --force
./configure => i don't know here

You should download PHP and then change to the ext directory and follow the tutorial. Don't forget to compile PHP too, because the extension you create depends heavily on the PHP version. I've installed OpenSuse but I don't think it does affect building a PHP extension. You might need some compiler tools etc. I found /php-5.2.6/ext/ext_skel in my PHP path. I've PHP installed in my home directory. You need to install the sources. In OS it's zypper in php5-devel. You can also download the tarball from the PHP site.
Edit: Here is another tutorial about php extension programming.

Related

Using Libsodium with PHP on WAMP

I'm having really hard trouble installing libsodium on my local server (WAMP64).
I used this guide and many others, but still no luck.
I successfully installed PEAR but I can't use it to install the PHP wrapper of libsodium. Can someone post a little guide step by step to help me?
I would appreciate help installing Halite, wich needs libsodium, because maybe it will be my next step.
Thank you everyone.
On Windows, download the appropriate zip file for your version of PHP and then follow these three steps. (I used 1.0.6 for PHP 7.0 in my testing).
Copy libsodium.dll to the System32 Folder or the same directory as php.exe. Also copy it to the apache/bin/ folder (for me that was C:\xampp\apache\bin).
Copy php_libsodium.dll to the PHP extension directory (C:\xampp\php\ext\ for me)
Add extension=php_libsodium.dll to your php.ini file.
The bolded part in step 1 is what I was missing. As soon as I placed the dll in that folder and restarted Apache, everything started working.
You can create a new php file with this code to verify it is working properly:
<?php
var_dump([
\Sodium\library_version_major(),
\Sodium\library_version_minor(),
\Sodium\version_string()
]);
Do Not Try To Install Pecl Extensions On Windows With Pear/Pecl. It Will Not Work.
Rather use pre-compiled .dll file.
The guide page even says so:
Installing Libsodium and the PHP Extension on Windows
On Windows, download the appropriate zip file for your version of PHP and then follow these three steps.
goto WAMPSERVER and install listed PHP
Enable sodium and check in 'Show PHP loaded Extensions' it will get loaded
check-in PHP module if sodium is available or not with the following command
cmd> php -m
cmd> php --ri sodium
if sodium is not listed then go to your /php/php.ini and search for ';extension=sodium' and remove ';' you will be good to go

MAMP PHP 5.6.2 errors compiling redis.so

I have been trying to compile a redis.so extension for MAMP using PHP 5.6.2 and I am getting a compiling error. Mostly ‘compiler_globals’ undeclared, but a couple other Zend related ones. I have spent hours trying to get this working.
If I try to compile using PHP 5.5.x as a source I do not have any issues.
Is there anyone who has successfully compiled a redis.so for 5.6.x? If so is it possible to get it posted for download? Anyone have any suggestions as to how to compile without errors?
Please don't post links to instructions on how to do the redis.so compilation as I have read gone through them and it is not working. Thanks.
You will want the source code for PHP. Download it and rename the folder to php. Put this folder into a include folder in the MAMP php directory.
Before ./configure your extension, be sure to run ./configure in the php directory. This will create the proper header files needed for the extensions.
Also, you want to phpize from the Mamp version of php that you are running.
$ /Applications/MAMP/bin/php/php5.3.29/bin/phpize

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.

Compiling a PHP extension for windows

I've previously managed to get XHP compiled in a Linux environment with the .so extension. I'm trying to compile it for use in a windows enviroment (.dll) and I've followed the following tutorial on php.net but after I buildconf, I fail to see the extension under configure --help (I downloaded the source at put the source folder in ext directory). Any help would be appreciated.
I'm using Visual studio 2008 and looking to compile extension for PHP 5.4.
XHP doesn't have a config.w32 file to support the Windows build environment (see Build for Windows.
Windows uses a different build system than Linux so it requires a different config. I remember manually converting a config.m4 to a config.w32 for a tutorial on how to write your own PHP extension and it was relatively painless. It could have been that way because it was simple compared to XHP's config.m4.
It wouldn't hurt to copy the contents of config.m4 to config.w32 and try to build it to see what happens.

How to get Buildconf & Configure scripts for PHP5

Am trying to install a package which has given instructions to use Buildconf from the root of php build directory. In my php build directory's root(/etc/php5), I don't find a Buildconf or Configure script. How do I get these? I installed my php5 using sudo apt-get(yes, I have an Ubuntu).
What you probably have installed is PHP binary package, i.e. already built one. If you need to build a stand-alone PHP module, you may want to install package php5-dev and use utility /usr/bin/phpize5 to generate config files.
If what you really need is PHP source, you may download it from http://www.php.net/downloads.php. After you unpack the package, buildconf will be there.
If neither of these is what you need, I guess it would be helpful to post the instructions you received.

Categories