arangodb / arangodb-php

PHP ODM for ArangoDB
https://www.arangodb.com
Apache License 2.0
183 stars 46 forks source link

Native PHP extension / driver which uses fuerte and velocypack #232

Open sandrokeil opened 7 years ago

sandrokeil commented 7 years ago

Are there any plans to create a native PHP >= 7.1 extension of this library to increase overall performance in PHP? Something like node-arangodb-cxx.

Have you any idea which performance gain can be expected with this or do you think it's not worth the effort?

jsteemann commented 7 years ago

@sandrokeil: this is a good idea and we also thought about that a bit. From my experience with the native driver for node.js I would expect that the performance gains from using a native extension for request/response processing and the JSON/VelocyPack handling should be there, though they potentially would vary a great deal from use case to use case. I'd expect to see nice speedups for use cases that process bigger requests/responses. However, it will be a major effort to write a native extension. I do not have a good idea how long this would take as I did not write any serious PHP extension for about 10 years, and have no idea how the extension API now looks like. But it's still a huge effort to get the type mapping right and up to speed. If anyone volunteers to provide the basic stubs and a build environment for a native extension, that would be a good starting point, and I think we could help out then. But I do not see ourselves writing a native PHP extension in the next few weeks due to lack of time. This may change however and it may get back on our radar.

sandrokeil commented 7 years ago

Maybe it's a bit easier to use the php-cpp project for this. They have also async stuff which can be used and some examples can be found there.

sandrokeil commented 7 years ago

There exists a project lucassouzavieira/arangodb-php-driver which uses zephir.

@lucassouzavieira have you compared php-cpp and zephir? If so, can you say the advantages over php-cpp? Have you think about to use fuerte as foundation?

lucassouzavieira commented 7 years ago

@sandrokeil, this is exactly the idea of ​​the project with Zephir. The extension will work natively with PHP 7+.

About PHP-CPP: I considered using it for the native driver, but Zephir seems to me a more interesting option. Anyway, the Zephir documentation is very broad and the integration with the Zend Engine API is very good.

It is very easy to develop with Zephir, especially for those who already develop with PHP. It is also natively memory-safe and cross-platform.With PHP-CPP I might have to worry about interoperability between different platforms. If I had chosen PHP-CPP, I would certainly use the fuerte base.

sandrokeil commented 7 years ago

@lucassouzavieira Thanks for your reply.

If I had chosen PHP-CPP, I would certainly use the fuerte base.

Does this mean, that fuerte would not work with zephir? Because the docs says, you can also use any cpp library?

I think, if someone works on a native PHP driver, they should rely on fuerte, because of velocypack and other features. Like node-arangodb-cxx and build an abstraction like the ArangoDB PHP lib on top of that. Any idea how we can join the work to get things done?

I have created some ArangoDB types which are pretty handy, I guess. Not sure if it is useful for the official lib too? /cc @jsteemann

@frankmayer You have some ArangoDB libs like ArangoDB-PHP-Core-Guzzle. You also interested in more performance and async stuff?

lucassouzavieira commented 7 years ago

@sandrokeil, I agree with you regarding that new native driver support the velocypack.

Because the docs says, you can also use any cpp library?

We can include C libraries in the build process. If we have a C binding for the velocypack, it can be included in the driver. Although the velocypack is written in C++, i believe it is possible to use its functions in C. Check this. In this way, we can add velocypack support in the arangodb-php-driver. The same can be done for the fuerte.

In my view, it's better than rewriting a new native driver again.

sandrokeil commented 7 years ago

@lucassouzavieira / @jsteemann I've build a php-cpp Docker image to build the extension and I've created a arangodb-php-driver respository and it looks like the extension can be build with fuerte and velocypack. :tada:

Next step could be a velocypack and fuerte call to see if this works. Maybe we can simply port node-arangodb-cxx to PHP.

lucassouzavieira commented 7 years ago

@sandrokeil, I'll take a look at your repository. I believe that the Velocypack and other features of the fuerte can be included without problems in the repository that I have been working on. Only C binding would be required for the fuerte and velocypack projects in C++.

@jsteemann, can you say something about it? What do you think about that ?

sandrokeil commented 7 years ago

@lucassouzavieira It would be great if this works, so I guess we can go this way. I don't know if it does matters which tool we use to build the extension. Do you know if Alpine Linux is supported?

sandrokeil commented 7 years ago

Simple velocypack call works. Small progress but I guess my build is ugly and I have new linking issues.

sandrokeil commented 7 years ago

Kudos to @martin-schilling :-) Now velocypack and fuerte are working. A collection was created, but the script is hanging. I don't know if it's a fuerte or PHP extension problem. /cc @jsteemann

sandrokeil commented 7 years ago

It looks like it is also possible to use the ArangoDB go driver with php-go or even with go-php.

sandrokeil commented 7 years ago

It looks like the go variant is not an option, but this PR is a game changer. :tada: