0

I have one simple page with two methods, one to charge data into inputs and other to save then. Both methods are using FFI to access one pascal dll, but I need to initialize the dll at the first method called and keep the handle to be used at the nexts calls. I'm using PHP 8.3, and the dll methods are working fine at the first call.

I can't find one way to keep de state of the variable to be used at the nexts requisitions, FFI don't allow to serialize and if I keep the pointer with session variável, when I load the dll again, setting that pointer, I have access violation. Have some option to use one global variable to keep the FFI initialized at the first method to be used at the nexts calls?

5
  • 1
    Don't try to keep handles between script executions. Get a handle, use it and close it within a single request. Commented Aug 18, 2024 at 18:08
  • Thanks to answer, but the dll have some chield methods and need to be alive, example: charge one XML, after I can assign, validate, print... Commented Aug 18, 2024 at 18:59
  • The only way to keep the DLL in memory would be to run PHP as an Apache module and enable FFI preloading. But personally I would only do that as a last resort. Commented Aug 18, 2024 at 20:10
  • To this dll I really need to find a way to keep FFI between the calls. I will to try your sugestion. Thank you so much Commented Aug 19, 2024 at 8:36
  • I tried using preloaling, but it doesn't work on Windows and I need it to work on any operating system. thanks for the help. Commented Aug 20, 2024 at 19:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.