A
A
Alex2021-08-10 22:32:03
PHP
Alex, 2021-08-10 22:32:03

Get Image from Deno JS in PHP?

There is a JS script. Is it possible (if so, how better) to run a script in PHP via Deno and get an image in response (for example, in uint8array)?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Shamanov, 2021-08-10
@SilenceOfWinter

purely theoretically - yes, there is a v8js extension , but in practice it's easier to rewrite the code in php or ajax to transfer the result to php

K
Kirill Nesmeyanov, 2021-08-11
@SerafimArts

If deno has cdecl, fastcall or stdcall abi exported functions, then just use the usual sish headers to declare it and access the code directly from puff via FFI: https://www.php.net/manual/en/ffi.cdef. php
And uint8 is char, so it is packed with pack('C*', $array) and unpacked back in the same way: https://www.php.net/manual/ru/function.pack.php
PS I checked that Deno does not have any export functions, except for the one that is incomprehensible for crashes: https://habrastorage.org/webt/mq/ye/5v/mqye5v1pqkb...
And this means that you will need to either rebuild it by hand, throwing the necessary functions out so that it was possible to call them, or somehow perverted in some other way.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question