質問

I'm attempting to create a PHP extension/wrapper for a C library. I have followed this tutorial Extension Writing Part I very closely and have bought the book "Extending and Embedding PHP" from the same author.

I am working on a MAC and have MAMP installed.
I have downloaded and installed make-3.82, autoconf-2.69, automake-1.9 and libtool-2.4.2 without problems. I have created a hello folder in the Applications/MAMP/bin/php/php5.4.4/lib/php/extensions folder and have created the files listed in the tutorial above exactly as instructed.

I did these three steps:
$ phpize
$ ./configure --enable-hello
$ make

Again no problem.

But when calling the php -r 'echo hello_world();' I get an 'undefined function hello_world' error.

I know that several of the steps listed above are not the recommended way to do this.
Am I in the wrong folder for extensions? The extensions folder is not the folder recommended but I couldn't find an ext folder anywhere.

Do the more current versions of these additions work the same as the old ones or do I need to go back to the earlier versions?

Is there a more current set of instructions for putting together an extension for PHP that anyone can recommend?

役に立ちましたか?

解決

On further research I found that my MAMP install is missing an includes directory tree which contains the ext folder referred to in all of the current documentation. I don't know if that is simply an upgrade or not but I am going to abandon this and switch to a Linux environment for development.

EDIT: So having fought with the same problem on Linux I discovered a file in etc/php5/apache2/conf.d called the name of the existing extension with the same extension = {extension}.so line that is also in the php.ini. When I duplicated that file with my own extension information the extensions began to function. This file was not anything I saw referred to in any of the documentation I reviewed. I do not know if there is a corresponding file in the MAMP environment that was also causing the issues there.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top