I have been leaning towards Zephir for a PHP extension I'd like to write - but due to limited support for native numerical data-types, Zephir may complicate some of the things I'd like to do, and/or work-arounds would lead to inferior performance.
I don't have any real experience writing PHP extensions, and no C experience to speak of, so Zephir is tempting - but I have a feeling that macros in Nim could facilitate writing PHP extensions more elegantly than Zephir.
Has anyone attempted to write a PHP extension in Nim?
We are working on both: PHP Codegen and simple Nim native PHP extension at METATEXX.
Both are WIP, unfinished and unsupported. Documentation is currently not existing and there will be many changes. First proof of concepts are very promising though.
As @araq is full time employee at METATEXX since the beginning of this year we have good hopes to make that work in production.
If you are interested in watching progress for native Nim -> PHP Extension you can check it out in this repository: https://github.com/metatexx/nimzend
Example "Extension":
import nimzend
proc nimgreeter(s: string) {.phpfunc.} = return_string "Hello " & s
finishModule("nimgreets", "0.1")
Using the prepared config_tpl.nim it is easy to build (if it is supported for your PHP at all. We only have 5.3 and 5.4 in our tests right now.)
> nim build nimgreets.nim
Installing to: /usr/local/Cellar/php54/5.4.45_3/lib/php/extensions/no-debug-non-zts-20100525
> php -r 'dl("nimgreets.so"); echo nimgreeter("World").PHP_EOL;'
Hello World
P.S.: It is known that you can have only one Nim extension loaded right now. Also there are a multitude of memory related problems. Keep in mind: WIP / proof of concept.
UPDATE: It is now possible to compile simple modules for PHP 5.3 up to PHP 7.0
This is very cool @OderWat .. wonder what you are using it for at your company -- just prototyping new extensions or actually really for implementing extensions. Is it still in development?
Can i use operator overloading with it? Would need this for an extension i would like to build ...