How to load external extensions

Problems with the Windows version of XAMPP, questions, comments, and anything related.

How to load external extensions

Postby trejder » 17. April 2023 15:22

This is a follow up to my Stack Overflow question.

It seems that I am doing something wrong or PHP under XAMPP 8.2.4 is unable to load my external library (I am trying to load php_lzf to add LZF compression support to my PHP).

I have:
  • copied the corresponding file to C:\XAMPP\php\ext folder
  • added extension=lzf to php.ini

But when I try to run PHP it says that the module file cannot be found (screenshot).

What else should I test or do? I did some extra tests (as described in comment to my Stack Overflow question) to make myself sure that the correct php.ini file is being loaded and that the other extensions from the same php.ini (and the same extensions folder) are being loaded without any problems. Only in case of my extra extension there seems to be a problem.

To be honest, I have absolutely no idea, what is going on here. I have two files -- php_lzf.dll and php_sqlite3.dll (and many more of course) -- residing in C:\XAMPP\php\ext folder, I have two entries -- extension=lzf and extension=pdo_sqlite (plus many more) added to my php.ini file and the first one of them is not being loaded (and PHP claims that the file is missing -- the weirdest part) and the second one (plus many more) is being loaded without any problems at every PHP startup. This is so weird case that I don't even know where to start tracing it.
trejder
 
Posts: 68
Joined: 13. April 2008 06:45

Re: How to load external extensions

Postby Nobbie » 17. April 2023 18:34

You cannot add "your own" DLL to the PHP extensions. You can only activate extensions, which are coming with the Xampp installation. The DLLs. have to fit precisely(!) the infrastructure of the Xampp Build (many parameters have to be fullfilled), which is quite impossible to achieve.

You will finally get error messages that your own DLL cannot be loaded for many reasons. If you need to have LZF extension, you cannot use Xampp.
Nobbie
 
Posts: 13176
Joined: 09. March 2008 13:04

Re: How to load external extensions

Postby trejder » 17. April 2023 19:02

You are completely surprising me. I am honestly destroyed. For 10+ years I was more than sure that XAMPP is a software package that simply binds Apache + PHP + MySQL etc., allowing easy startup and configuration and... nothing else.

Now you are saying that it deeply modifies these, introducing its own infrastructure? Can you explain me, for what reason? Or what do I get out of it?

Because for me XAMPP is nothing more than XAMPP Control Center -- that is a "bunch of buttons" that allows me to quickly start each component, check logs, access configuration or check ports. Nothing that I couldn't achieve manually or myself, without XAMPP. It would only be less convenient.

So, what is exactly my "added value" out of this whole XAMPP Build Architecture (or whatever it is) which disallows me from using official PHP extensions (LZF extension comes from PELC so is official)?

I am asking seriously. Not being able to use other extensions is a great disadvantage for me when it comes into using XAMPP. I'd like to learn for what reason or for the sake of what I am having this disadvantage?
trejder
 
Posts: 68
Joined: 13. April 2008 06:45

Re: How to load external extensions

Postby Altrea » 17. April 2023 21:28

Hi,

XAMPP for Windows is using the default binaries from php.net (VS16 (Visual Studio 2019) x64 TS).
So if you want to be able to load your extension, it needs to be build against this environment.

Most problem of not loading user or other third party dlls are that they are not build against this environment.
Did you read and follow this: https://wiki.php.net/internals/windows/ ... uild_sdk_2 :?:
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11936
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: How to load external extensions

Postby trejder » 17. April 2023 22:33

OK, thank you for you explanation. I see your point now.
trejder
 
Posts: 68
Joined: 13. April 2008 06:45

Re: How to load external extensions

Postby Nobbie » 18. April 2023 21:28

trejder wrote:Now you are saying that it deeply modifies these


Could you point out precisely where i said that Xampp "deeply modifies" these, and please also explain what is meant by "these". These what? I simply told you, that Xampp (of course) is build in a certain "infrastructure", Altrea uses the word "environment" instead, what means exactly the same in this context.

Where did i say something about "deeply modifies"?
Nobbie
 
Posts: 13176
Joined: 09. March 2008 13:04

Re: How to load external extensions

Postby hashirshabbir » 06. December 2023 06:28

There are a few possible reasons why the php_lzf extension is not being loaded, even though you have added the extension=lzf line to your php.ini file.

First, make sure that the php_lzf.dll file is actually in the C:\XAMPP\php\ext folder. If it is not, copy it there.

Second, make sure that the php.ini file is being loaded correctly. You can check this by running the following command from the command line:

php -i
This will print out a lot of information about your PHP installation, including the path to the php.ini file that is being used.

Third, make sure that the php_lzf.dll file is compatible with your version of PHP. You can check this by looking for the following line in the php_lzf.dll file:

ZEND_MODULE_VERSION 20131025
If the version number is not compatible with your version of PHP, you will need to download a newer version of the extension.

Fourth, make sure that the php_lzf.dll file is not corrupt. You can check this by trying to load the extension using the following command from the command line:

php -d extension=lzf
If the extension loads successfully, then the file is not corrupt.

If you have checked all of these things and the extension is still not loading, then there may be a problem with your PHP installation. You may need to reinstall PHP or contact your hosting provider for help.
hashirshabbir
 
Posts: 2
Joined: 03. December 2023 09:18
XAMPP version: 8.0.0
Operating System: window 10

Re: How to load external extensions

Postby trejder » 06. December 2023 10:24

Nobbie wrote:
trejder wrote:Now you are saying that it deeply modifies these


Could you point out precisely where i said that Xampp "deeply modifies" these, and please also explain what is meant by "these". These what? I simply told you, that Xampp (of course) is build in a certain "infrastructure", Altrea uses the word "environment" instead, what means exactly the same in this context.

Where did i say something about "deeply modifies"?


"Deeply" is just a wording.

For some reason I was more than sure that to add some missing PHP extension, all that I need to do is to provide some .dll file, change configuration .ini and restart Apache. Nearly everyone can do this.

With yours and others explanation it turned out that to achieve the above, I have to recompile XAMPP from source in VC++. Not everyone can achieve this. Not me. I don't have Visual Studio installed and I know virtually nothing about C++. That's what I call "deep" modification.

It is not a modification in fact. It is rebuilding the whole bundle from scratch based on sources. I thought that adding new, missing PHP extension is a configuration modification level only.
trejder
 
Posts: 68
Joined: 13. April 2008 06:45

Re: How to load external extensions

Postby trejder » 06. December 2023 10:31

hashirshabbir wrote:If you have checked all of these things and the extension is still not loading, then there may be a problem with your PHP installation. You may need to reinstall PHP or contact your hosting provider for help.

Thanks for trying to help and bringing all the detailed step-by-step documentation. I will give it a try in my first spare time.

However, I think that this will not change anything. As others have already explained, it seems that I have to rebuild the whole environment from scratch, recompile sources to add some missing extension.

BTW: Since the above, I decided to change parts of the code to not use LZF library at all at all.

BTW: I am talking about my own development environment, so unfortunately I am myself a hosting provider and must provide help with this issue myself.
trejder
 
Posts: 68
Joined: 13. April 2008 06:45


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 148 guests