PHP: Errors installing composer in XAMPP on Windows

I have a XAMPP installation on a Windows machine and wanted to install Composer. After downloading it from getcomposer.org I started the installer. After the step where you have to point it to php.exe, I got many error messages along the lines:

Unable to load dynamic library '\software\xampp-portable\php\ext\php_bz2.dll'

I probably got around 20 error popups. The first thing I did was to check whether the library was in there. And it was. Only then did I notice that the path shown didn’t include the drive name. Since I had just shown the installer where php was installed, I thought that it was probably reading the path from the associated php.ini and maybe the path wasn’t complete there. And I was right:

; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
extension_dir = "\software\xampp-portable\php\ext"

After modifying it to:

extension_dir = "d:\software\xampp-portable\php\ext"

And the errors were gone !

5 thoughts on “PHP: Errors installing composer in XAMPP on Windows

    1. The problem is that XAMPP is actually not really portable. Even without the drive name in the path it still references the directory where it is installed. So if you use a USB-Stick and everything is in the root of the drive then it is kind of portable. Or if you copy it to another computer in the same path (no matter which drive) then it is also “portable”.

      If you do not add the drive name to the path in php.ini, you open a shell from the XAMPP control UI, go to another drive and execute a simple php -v you will get an error message. So I assume that the composer installer might work fine if you explicitely start it from the same drive where XAMPP portable is installed but I am not sure. Anyway, I think I’ll have to live with the fact that if I have XAMPP on a different path after moving to a different computer, I’ll have to change the path in php.ini since XAMPP portable is not 100% functional if the drive name is missing.

      If the paths in php.ini were relative to the location of php.exe used and not relative to the current directory, we wouldn’t have this mess…

Leave a Reply

Your email address will not be published.