Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sandrokeil opened this issue Oct 10, 2017 · 13 comments
Open

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

sandrokeil opened this issue Oct 10, 2017 · 13 comments

Comments

@sandrokeil
Copy link
Contributor

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
Copy link
Contributor

@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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link

@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
Copy link
Contributor Author

@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
Copy link

lucassouzavieira commented Oct 11, 2017

@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
Copy link
Contributor Author

@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. 🎉

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
Copy link

@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
Copy link
Contributor Author

@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
Copy link
Contributor Author

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

@sandrokeil
Copy link
Contributor Author

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
Copy link
Contributor Author

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

@sandrokeil
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants