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.
Related
I'm on Windows 10, and I really need to install this PHP extension in order to use advanced GeoPHP methods. I've already asked about this previously here. There is no available DLL for this extension, and the instructions for installation on GitHub are for Linux. What I've understood is that I need to recompile PHP with the extensions in the ext folder, so I'm planning on doing that using these instructions. However, I've previously installed PHP through XAMPP.
My question is, will these instructions work with this? If yes, where can I find the PHP source files? I'm not quite sure what they look like, and googling "PHP source files location" gives me stuff about actual PHP files, not the ones used for installation. I just want to make sure. Thanks.
No, you do not have to recompile PHP. The module you stated is not baked into PHP but dynamically included.
Just build the module and include it like
extension=geos.dll
The Github link you posted does have instructions...
I have VSCode installed, but don't seem to have php - i.e. there is no "php.exe" anywhere on my computer. No guides that I can find on the web about setting VSCode up for PHP suggests that I need to download and install php itself seperately (only debuggers and linters)... my question is:
Do I need to install PHP seperately? Should I have had to do this, or is there a bug in my VSCode installation...
Yes you need to install PHP from the php website and then tell VSCode where PHP.exe is located.
VSCode is an editor not an interpreter.
I think if you install PHP at the default location VSCode will automaticly pick it up but if not you need to specify its path in options.
If you install XAMPP you will get apache,php and mySql in one installation.
EDIT: an interpreter is software that translated your code(in your case PHP) into code that the CPU can understand and then executes.
#kpollock it' not you. Yes, it should seem obvious that the language should be installed manually or separately, so you should have gotten that part, sorry. But no, there doesn't seem to be information anywhere about defining the underpinnings. This "understanding" seems to be left to the individual through research as you're doing.
After I installed PHP I manually set my environment PATH to include the PHP folder. OR in VS Code you can go to menu>File>Preferences>User Settings, the settings are maintained as a JSON object (unlike VS) and there is a PHP section for the .exe path.
Since you mentioned Node, you may not have installed Node.js manually. (I don't know if Node comes with VS Code either.) It might have come in with a VS2015 extension like Gulp or some other higher-level functionality, or maybe it was an installation option with VSC. If you can't use node or npm from a console, set your environment PATH to include it.
Today I have tried to install imagick in my xampp a hundred times. And I did it. If you have troubles, please try following these steps:
Since xampp is x86, check if your Image Magick (the program) is x86. If not, download the latest version here: imagemagick.org/script/binary-releases.php#windows
Please remember that u MUST download the Win32 dynamic at 16 bits-per-pixel.
Install Image Magick at C:\imagemagick.
Download the latest stable version of imagick here: . You MUST download the 5.x Thread Safe (TS) x86. The x in 5.x is the version of your PHP.
Put the php_imagick.dll in php/ext folder of your xampp installation.
Add this in your php.ini: extension=php_imagick.dll
Here is when I have a lot of trouble. If you try to start the server (or writing php in the console (start->cmd)), you will get an error. If that error says something like this: Unable to find the entry point for the procedure FlattenImages in the DLL CORE_RL_magick.dll it means that you're well underway.
Now, you must go into the installation folder of Image Magick and overwrite the DLL you downloaded with the php_imagick.dll. All of them start with the prefix CORE_RL_.
Once you overwrote all of them, you can try writing php in the windows console. I don't say something means that the imagick is functional (you can check in localhost/xampp/ > phpinfo() link. Personally, I had to install a new DLL: vcomp110.dll.
If someone has the same error as me (the system can't found the vcomp11.dd) download it here
Now, if you try executing php on console, or just initializing the apache module of xampp, you should not have errors.
Goodbye and hope I can help someone.
EDIT: when tried to convert some-img.bmp some-result.jpg in the console, I had this error:
convert.exe: unable to open module file 'C:\Users\my-acc\.magick\IM_MOD_RL_BMP_.dll': No such file or directory # ...
This happened when there is no folder .magick in my-acc. The thing you need to do is this:
Create a folder named .magick in the my-acc folder. Since the name starts with a stop, you need to create it through the console. Here are the commands:
1.1. c:
1.2. cd Users\my-acc
1.3. mkdir .magick
Go to C:\imagemagick\modules\coders and copy the entire files into the latest folder created.
Now, you will be able to use Image Magick through the commands or the PHP Classes.
On background, if you use Codeigniter, i have no idea how to use the image_lib with imagick. So, it's better with the own imagick classes. Here a simple example:
$image = new Imagick($upload_data['full_path']);
$image->thumbnailImage(250,0);
if($image->writeImage($upload_data['file_path'].$upload_data['raw_name'].'_thumb'.$upload_data['file_ext'])){
something here;
}
$image->clear();
This answer might be extremely naive, but, I've found that getting things done in Windows is generally too painful. Many people agree with that and have found solace in a tool known as "chocolatey".
First, install chocolatey on your Windows machine (super easy install instructions):
https://chocolatey.org/
Then, use chocolatey to install everything else that you need (imagemagick in this case):
https://chocolatey.org/packages/imagemagick
I suspect you might have to do some minor tweaking to configuration files after that, plus handle all of the "Windows permissions" needed to get things to work smoothly. Permissions are can be as simple (and not necessarily safe) as "full control" to some user, plus activating inheritance and overwriting all children's settings to use inheritance.
In short, install, configure, permissions, go.
PS. This answer might be incomplete/prototypical/experimental, since I don't run codeigniter, php, imagemagick on Windows.
This how-to of Winderfind is wonderful, but for me it was not yet complete to troubleshoot all problems. First of all, have a look at this tutorial:
http://hrt0kmt.hatenablog.com/entry/2015/05/27/170608
Secondly I discovered that not all versions of ImageMagick will work with all versions of php_imagick.dll. Check out my and others answers on this post for further troubleshooting:
ImageMagick supported formats no value
Great tutorial,
If you are running windows 11, and installing xampp with php 8.1, you need to install 64bit versions:
Win32 dynamic at 16 bits-per-pixel
Becomes
Win64 dynamic at 16 bits-per-pixel
And
5.x Thread Safe (TS) x86
Becomes
8.1 Thread Safe (TS) x64
If you've installed the 32bit versions (as I did), you can just download the 64bit versions and overwrite all the files. Then restart apache and it should start working.
I have come across this question which states exactly my problem, except that I'm using Wamp, not Xampp.
Symfony 2: Install and enable the intl extension
Though I enabled php_intl extension through the Wamp drop down menu, and making sure that the extension was not commented out in my php.ini configuration file, Symfony just keeps recommending me to enable intl extension.
I have visited the link in the accepted question:
http://php.net/manual/en/intl.requirements.php
Still no luck. I have visited the ICU Homepage and even attempted to download it, and then I just don't know what file to download or what link to follow.
I'd like someone who can point me to the right direction. I'm quite new to PHP (only two sites developed with it), and am a total beginner with Symfony. And I also can't understand all those tricks with Pearl, PECL, Composer, etc. I feel completely lost.
Thanks for any help.
Check the comments when you are using the app/check.php script:
* Configuration file used by PHP: /etc/php5/cli/php.ini
** ATTENTION **
* The PHP CLI can use a different php.ini file
* than the one used with your web server.
* To be on the safe side, please also launch the requirements check
* from your web server using the web/config.php script.
Make sure intl is enabled in the right php.ini file.
For getting started with Symfony I strongly recommend the video's from KNP University (knpuniversity.com). I thought they were excellent to get me started with Symfony. For composer enter $ php composer.phar list in the terminal to view all the options that come with composer.
After having searched and searched again and again, I have found that the history information of my browser fooled me.
First, I have copied the icu*.dll files from my %WAMP_INSTALL_DIR%\bin\php\php5.4.12 to my %WAMP_INSTALL_DIR%\bin\apache\Apache2.4.4\bin as mentioned here: intl extension php_intl.dll with wamp, and restarted all of my services.
Then, I had the idea of clearing my history, after having copied the files as above-mentioned, and it worked!
I do hope this will help others.
I am using a Windows XP Home Edition. I need to install a few extensions to PHP -- memcache, APC, .etc. And I would very much like to use PECL to make this happen. The problem is PECL takes it for granted that I will have certain programs on my computer. On another post, I read, for instance, that you need to have Microsoft Visual Studio C++ installed on your machine. However, the new version of Visual Studio, which I downloaded, does not have msdev.exe and instead uses vcbuild.exe, which has a completely different api and fails to compile the .dsp files that come with these modules.
So I tried to find a script that would upgrade the dsp to work with vcbuild.exe...and it turns out vcbuild.exe can do that, but of course that didn't pan out.
Another thing I tried was to find a make script for Windows (nmake2make). But there was no make file in the module's root folder.
I tried also downloading Cygwin and MinGW in hopes of finding a build script that would work as simply as in *nix operating systems, but to no avail.
How else do I use install PHP extensions on a Windows machine? Can anyone help me out of this predicament?
For all peoples coming here to download the dll extension files.
This is the link to the PHP extension download link http://windows.php.net/download/
And this is a list of PHP extensions to download: http://pecl.php.net/package-search.php
For core extensions, or if you cant find any on pecl.php.net, download PHP from a zip http://windows.php.net/download/ and look inside of /ext and copy them to your local php /ext folder.
The only way I can think of is: manually. Yeah, I know, but this is pretty easy comparatively.
If you have the compiler, then you can at least compile an extension if you have the source. Otherwise you're stuck with trying to locate a binary distribution (like me).
Here's what you do, from what I understand:
Put the extension library folder under PHP's install path. On my computer this is C:\xampp\php\ext. Search in your PHP.ini for "extension_dir" to find what yours is.
Edit php.ini to load the extension.
Find ; Dynamic Extensions ;.
Add line extension=my_lib.dll
This should do it. Otherwise you should probably search for an in-depth guide on manual installation.
For memcache you will need the memcache server located here -> http://code.jellycan.com/memcached/ and download the win32 binary
Never used APC :P I use eAccelerator0953_5.2.6 to cache the code