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

can you show more code example? #52

Open
MariaWf opened this issue Feb 1, 2018 · 3 comments
Open

can you show more code example? #52

MariaWf opened this issue Feb 1, 2018 · 3 comments

Comments

@MariaWf
Copy link

MariaWf commented Feb 1, 2018

Your idea is very good, but I still do not really understand and understand your library package, you can introduce it in more detail?

@deuill
Copy link
Owner

deuill commented Feb 1, 2018

Hi, more documentation is definitely on the roadmap (has been for a while...), but the tests should help a lot with understanding how to operate most of the specific APIs. As far as an introduction goes, does this work?

This package allows for embedding PHP in Go applications, calling code and sharing data between implementations efficiently. For instance, you can:

  • Use most types of Go variables in PHP as their equivalent types (int to integer, float to double, struct to stdClass, slice to array, etc), as well as return PHP variables back into Go.
  • Use Go method receivers (i.e. custom types with attached functions) as PHP classes transparently.

Integration between Go and PHP is done by means of linking against the PHP interpreter, which leads to minimal overhead in translation between representations.

It also allows for progessively replacing parts of the application stack with Go, for instance, instead of deploying a standard Apache/NGINX and PHP-FPM stack, you can use this package to handle incoming traffic using Go's built in HTTP server, and call through to PHP as needed.

Having go-php act as an intermediary makes it possible to transparently extract and re-build performance-sensitive functionality in Go, without having to refactor other parts of the application.

@adamlc
Copy link

adamlc commented Mar 19, 2018

One thing it might be worth mentioning is recommended ways on how to install PHP on various platforms so it can be compiled, for starters maybe the following:

  • MacOS
  • Windows 10
  • Ubuntu
  • Docker builds (I can see the Docker files already exist)

@deuill
Copy link
Owner

deuill commented Mar 19, 2018

Indeed, though it's possible to side-step the issue by using the Docker images provided and using those as the build environment. Distributing static libraries built against static PHP builds may also be useful, but their use might be a bit more narrow, depending on which modules we include.

I'll expand on the documentation with step-by-step instructions (though my ability to do so for MacOS or Windows is diminished).

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